TypeError: path.substring is not a function
mikolaje opened this issue · comments
After I intalled the package, I ran hexo g
, then it raised the errors:
Unhandled rejection TypeError: path.substring is not a function
at Object.urlForHelper (/home/dennis/hexo/blog/node_modules/hexo/lib/plugins/helper/url_for.js:9:31)
at wrapper (/home/dennis/hexo/blog/node_modules/hexo/node_modules/lodash/lodash.js:4941:19)
at Object.eval [as tpl] (eval at precompile (/home/dennis/hexo/blog/node_modules/hexo/node_modules/swig/lib/swig.js:498:13), <anonymous>:195:119)
at compiled (/home/dennis/hexo/blog/node_modules/hexo/node_modules/swig/lib/swig.js:619:18)
at Object.eval [as tpl] (eval at precompile (/home/dennis/hexo/blog/node_modules/hexo/node_modules/swig/lib/swig.js:498:13), <anonymous>:320:125)
at compiled (/home/dennis/hexo/blog/node_modules/hexo/node_modules/swig/lib/swig.js:619:18)
at Theme._View.View._compiled (/home/dennis/hexo/blog/node_modules/hexo/lib/theme/view.js:127:30)
at Theme._View.View.View.render (/home/dennis/hexo/blog/node_modules/hexo/lib/theme/view.js:29:15)
at /home/dennis/hexo/blog/node_modules/hexo/lib/hexo/index.js:387:25
at tryCatcher (/home/dennis/hexo/blog/node_modules/hexo/node_modules/bluebird/js/release/util.js:16:23)
at /home/dennis/hexo/blog/node_modules/hexo/node_modules/bluebird/js/release/method.js:15:34
at RouteStream._read (/home/dennis/hexo/blog/node_modules/hexo/lib/hexo/router.js:134:3)
at RouteStream.Readable.read (_stream_readable.js:457:10)
at resume_ (_stream_readable.js:933:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Unhandled rejection TypeError: path.substring is not a function
at Object.urlForHelper (/home/dennis/hexo/blog/node_modules/hexo/lib/plugins/helper/url_for.js:9:31)
at wrapper (/home/dennis/hexo/blog/node_modules/hexo/node_modules/lodash/lodash.js:4941:19)
at Object.eval [as tpl] (eval at precompile (/home/dennis/hexo/blog/node_modules/hexo/node_modules/swig/lib/swig.js:498:13), <anonymous>:195:119)
at compiled (/home/dennis/hexo/blog/node_modules/hexo/node_modules/swig/lib/swig.js:619:18)
at Object.eval [as tpl] (eval at precompile (/home/dennis/hexo/blog/node_modules/hexo/node_modules/swig/lib/swig.js:498:13), <anonymous>:320:125)
at compiled (/home/dennis/hexo/blog/node_modules/hexo/node_modules/swig/lib/swig.js:619:18)
at Theme._View.View._compiled (/home/dennis/hexo/blog/node_modules/hexo/lib/theme/view.js:127:30)
at Theme._View.View.View.render (/home/dennis/hexo/blog/node_modules/hexo/lib/theme/view.js:29:15)
at /home/dennis/hexo/blog/node_modules/hexo/lib/hexo/index.js:387:25
at tryCatcher (/home/dennis/hexo/blog/node_modules/hexo/node_modules/bluebird/js/release/util.js:16:23)
at /home/dennis/hexo/blog/node_modules/hexo/node_modules/bluebird/js/release/method.js:15:34
at RouteStream._read (/home/dennis/hexo/blog/node_modules/hexo/lib/hexo/router.js:134:3)
at RouteStream.Readable.read (_stream_readable.js:457:10)
at resume_ (_stream_readable.js:933:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
My hexo version:
hexo: 3.2.2
hexo-cli: 2.0.0
os: Linux 4.15.0-38-generic linux x64
http_parser: 2.8.0
node: 10.16.0
v8: 6.8.275.32-node.52
uv: 1.28.0
zlib: 1.2.11
brotli: 1.0.7
ares: 1.15.0
modules: 64
nghttp2: 1.34.0
napi: 4
openssl: 1.1.1b
icu: 64.2
unicode: 12.1
cldr: 35.1
tz: 2019a
I meet this issue after I upgrade to 2.1.1. And everything recovery after I go back to 2.0.0. The environment is MacOS with node13
Can you attach the config of this plugin (if any)?
Also can you try upgrading to Hexo v4?
The source of error could be
hexo-generator-feed/lib/autodiscovery.js
Line 15 in 9f1f7b0
which is added by 0d3e66c that is released into 2.1.0
My guess is that empty path
caused the issue. #113 + #111 should fix.
I've tried again but it does not work.
Following is part of the error log
2019-11-22T13:19:42.3204115Z TypeError: /github/workspace/themes/indigo/layout/layout.ejs:3
2019-11-22T13:19:42.3204911Z 1| <!DOCTYPE html>
2019-11-22T13:19:42.3205512Z 2| <html>
2019-11-22T13:19:42.3206176Z >> 3| <%- partial('_partial/head') %>
2019-11-22T13:19:42.3206624Z 4| <body>
2019-11-22T13:19:42.3207482Z 5| <%- partial('_partial/loading') %>
2019-11-22T13:19:42.3208131Z 6| <%- partial('_partial/menu') %>
2019-11-22T13:19:42.3208405Z
2019-11-22T13:19:42.3209111Z /github/workspace/themes/indigo/layout/_partial/head.ejs:51
2019-11-22T13:19:42.3210398Z 49| <%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
2019-11-22T13:19:42.3211108Z 50| <% if ((config.feed) && (config.feed.path.length)) { %>
2019-11-22T13:19:42.3212345Z >> 51| <link rel="alternate" type="application/atom+xml" title="<%= config.title %>" href="<%- url_for(config.feed.path) %>">
2019-11-22T13:19:42.3213150Z 52| <% } %>
2019-11-22T13:19:42.3214085Z 53| <%- favicon_tag(theme.favicon) %>
2019-11-22T13:19:42.3214847Z 54| <link rel="stylesheet" href="<%- url_for(theme_css('/css/style', cache)) %>">
2019-11-22T13:19:42.3215206Z
2019-11-22T13:19:42.3215940Z path.startsWith is not a function
2019-11-22T13:19:42.3217166Z at Object.urlForHelper (/github/workspace/node_modules/hexo-util/lib/url_for.js:16:31)
2019-11-22T13:19:42.3217826Z at Object.module.exports (/github/workspace/node_modules/hexo/lib/plugins/helper/url_for.js:6:18)
2019-11-22T13:19:42.3218412Z at eval (/github/workspace/themes/indigo/layout/_partial/head.ejs:111:17)
2019-11-22T13:19:42.3219179Z at head (/github/workspace/node_modules/ejs/lib/ejs.js:682:17)
2019-11-22T13:19:42.3219804Z at Theme._View.View._compiledSync (/github/workspace/node_modules/hexo/lib/theme/view.js:119:22)
2019-11-22T13:19:42.3220666Z at Theme._View.View.View.renderSync (/github/workspace/node_modules/hexo/lib/theme/view.js:48:23)
2019-11-22T13:19:42.3221333Z at Object.partial (/github/workspace/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
2019-11-22T13:19:42.3222083Z at eval (/github/workspace/themes/indigo/layout/layout.ejs:10:17)
2019-11-22T13:19:42.3222621Z at layout (/github/workspace/node_modules/ejs/lib/ejs.js:682:17)
2019-11-22T13:19:42.3223221Z at Theme._View.View._compiled (/github/workspace/node_modules/hexo/lib/theme/view.js:123:48)
2019-11-22T13:19:42.3223857Z at Theme._View.View.View.render (/github/workspace/node_modules/hexo/lib/theme/view.js:29:15)
2019-11-22T13:19:42.3224428Z at /github/workspace/node_modules/hexo/lib/theme/view.js:40:23
2019-11-22T13:19:42.3225006Z at tryCatcher (/github/workspace/node_modules/bluebird/js/release/util.js:16:23)
2019-11-22T13:19:42.3225676Z at Promise._settlePromiseFromHandler (/github/workspace/node_modules/bluebird/js/release/promise.js:547:31)
2019-11-22T13:19:42.3226324Z at Promise._settlePromise (/github/workspace/node_modules/bluebird/js/release/promise.js:604:18)
2019-11-22T13:19:42.3226969Z at Promise._settlePromise0 (/github/workspace/node_modules/bluebird/js/release/promise.js:649:10)
2019-11-22T13:19:42.3227612Z at Promise._settlePromises (/github/workspace/node_modules/bluebird/js/release/promise.js:729:18)
2019-11-22T13:19:42.3228228Z at _drainQueueStep (/github/workspace/node_modules/bluebird/js/release/async.js:93:12)
2019-11-22T13:19:42.3228818Z at _drainQueue (/github/workspace/node_modules/bluebird/js/release/async.js:86:9)
2019-11-22T13:19:42.3229435Z at Async._drainQueues (/github/workspace/node_modules/bluebird/js/release/async.js:102:5)
2019-11-22T13:19:42.3230506Z at Immediate.Async.drainQueues [as _onImmediate] (/github/workspace/node_modules/bluebird/js/release/async.js:15:14)
2019-11-22T13:19:42.3231150Z at processImmediate (internal/timers.js:439:21)
2019-11-22T13:19:42.3231660Z ERROR Render HTML failed: categories/index.html
2019-11-22T13:19:42.3232167Z TypeError: /github/workspace/themes/indigo/layout/layout.ejs:3
2019-11-22T13:19:42.3232699Z 1| <!DOCTYPE html>
2019-11-22T13:19:42.3233139Z 2| <html>
2019-11-22T13:19:42.3234142Z >> 3| <%- partial('_partial/head') %>
2019-11-22T13:19:42.3234600Z 4| <body>
2019-11-22T13:19:42.3235195Z 5| <%- partial('_partial/loading') %>
2019-11-22T13:19:42.3235816Z 6| <%- partial('_partial/menu') %>
2019-11-22T13:19:42.3236062Z
2019-11-22T13:19:42.3236498Z /github/workspace/themes/indigo/layout/_partial/head.ejs:51
2019-11-22T13:19:42.3237342Z 49| <%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
2019-11-22T13:19:42.3237945Z 50| <% if ((config.feed) && (config.feed.path.length)) { %>
2019-11-22T13:19:42.3238796Z >> 51| <link rel="alternate" type="application/atom+xml" title="<%= config.title %>" href="<%- url_for(config.feed.path) %>">
2019-11-22T13:19:42.3239559Z 52| <% } %>
2019-11-22T13:19:42.3240599Z 53| <%- favicon_tag(theme.favicon) %>
2019-11-22T13:19:42.3241386Z 54| <link rel="stylesheet" href="<%- url_for(theme_css('/css/style', cache)) %>">
2019-11-22T13:19:42.3241909Z
2019-11-22T13:19:42.3242530Z path.startsWith is not a function
2019-11-22T13:19:42.3243799Z at Object.urlForHelper (/github/workspace/node_modules/hexo-util/lib/url_for.js:16:31)
2019-11-22T13:19:42.3244438Z at Object.module.exports (/github/workspace/node_modules/hexo/lib/plugins/helper/url_for.js:6:18)
2019-11-22T13:19:42.3245026Z at eval (/github/workspace/themes/indigo/layout/_partial/head.ejs:111:17)
2019-11-22T13:19:42.3245682Z at head (/github/workspace/node_modules/ejs/lib/ejs.js:682:17)
2019-11-22T13:19:42.3246291Z at Theme._View.View._compiledSync (/github/workspace/node_modules/hexo/lib/theme/view.js:119:22)
2019-11-22T13:19:42.3246940Z at Theme._View.View.View.renderSync (/github/workspace/node_modules/hexo/lib/theme/view.js:48:23)
2019-11-22T13:19:42.3247544Z at Object.partial (/github/workspace/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
2019-11-22T13:19:42.3496812Z at eval (/github/workspace/themes/indigo/layout/layout.ejs:10:17)
2019-11-22T13:19:42.3497486Z at layout (/github/workspace/node_modules/ejs/lib/ejs.js:682:17)
2019-11-22T13:19:42.3498579Z at Theme._View.View._compiled (/github/workspace/node_modules/hexo/lib/theme/view.js:123:48)
2019-11-22T13:19:42.3499355Z at Theme._View.View.View.render (/github/workspace/node_modules/hexo/lib/theme/view.js:29:15)
2019-11-22T13:19:42.3500026Z at /github/workspace/node_modules/hexo/lib/theme/view.js:40:23
2019-11-22T13:19:42.3500726Z at tryCatcher (/github/workspace/node_modules/bluebird/js/release/util.js:16:23)
2019-11-22T13:19:42.3501505Z at Promise._settlePromiseFromHandler (/github/workspace/node_modules/bluebird/js/release/promise.js:547:31)
2019-11-22T13:19:42.3502325Z at Promise._settlePromise (/github/workspace/node_modules/bluebird/js/release/promise.js:604:18)
2019-11-22T13:19:42.3503182Z at Promise._settlePromise0 (/github/workspace/node_modules/bluebird/js/release/promise.js:649:10)
2019-11-22T13:19:42.3504019Z at Promise._settlePromises (/github/workspace/node_modules/bluebird/js/release/promise.js:729:18)
2019-11-22T13:19:42.3504886Z at _drainQueueStep (/github/workspace/node_modules/bluebird/js/release/async.js:93:12)
2019-11-22T13:19:42.3505667Z at _drainQueue (/github/workspace/node_modules/bluebird/js/release/async.js:86:9)
2019-11-22T13:19:42.3506398Z at Async._drainQueues (/github/workspace/node_modules/bluebird/js/release/async.js:102:5)
2019-11-22T13:19:42.3507210Z at Immediate.Async.drainQueues [as _onImmediate] (/github/workspace/node_modules/bluebird/js/release/async.js:15:14)
2019-11-22T13:19:42.3508195Z at processImmediate (internal/timers.js:439:21)
2019-11-22T13:19:42.3508801Z ERROR Render HTML failed: tags/index.html
2019-11-22T13:19:42.3509982Z TypeError: /github/workspace/themes/indigo/layout/layout.ejs:3
2019-11-22T13:19:42.3510767Z 1| <!DOCTYPE html>
2019-11-22T13:19:42.3511466Z 2| <html>
2019-11-22T13:19:42.3513004Z >> 3| <%- partial('_partial/head') %>
2019-11-22T13:19:42.3513719Z 4| <body>
2019-11-22T13:19:42.3514677Z 5| <%- partial('_partial/loading') %>
2019-11-22T13:19:42.3515887Z 6| <%- partial('_partial/menu') %>
2019-11-22T13:19:42.3516386Z
2019-11-22T13:19:42.3517070Z /github/workspace/themes/indigo/layout/_partial/head.ejs:51
2019-11-22T13:19:42.3518494Z 49| <%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
2019-11-22T13:19:42.3519425Z 50| <% if ((config.feed) && (config.feed.path.length)) { %>
2019-11-22T13:19:42.3520884Z >> 51| <link rel="alternate" type="application/atom+xml" title="<%= config.title %>" href="<%- url_for(config.feed.path) %>">
2019-11-22T13:19:42.3522048Z 52| <% } %>
2019-11-22T13:19:42.3523088Z 53| <%- favicon_tag(theme.favicon) %>
2019-11-22T13:19:42.3524359Z 54| <link rel="stylesheet" href="<%- url_for(theme_css('/css/style', cache)) %>">
2019-11-22T13:19:42.3524935Z
2019-11-22T13:19:42.3525630Z path.startsWith is not a function
2019-11-22T13:19:42.3527052Z at Object.urlForHelper (/github/workspace/node_modules/hexo-util/lib/url_for.js:16:31)
2019-11-22T13:19:42.3528324Z at Object.module.exports (/github/workspace/node_modules/hexo/lib/plugins/helper/url_for.js:6:18)
2019-11-22T13:19:42.3529213Z at eval (/github/workspace/themes/indigo/layout/_partial/head.ejs:111:17)
2019-11-22T13:19:42.3530185Z at head (/github/workspace/node_modules/ejs/lib/ejs.js:682:17)
2019-11-22T13:19:42.3531295Z at Theme._View.View._compiledSync (/github/workspace/node_modules/hexo/lib/theme/view.js:119:22)
2019-11-22T13:19:42.3532412Z at Theme._View.View.View.renderSync (/github/workspace/node_modules/hexo/lib/theme/view.js:48:23)
2019-11-22T13:19:42.3533517Z at Object.partial (/github/workspace/node_modules/hexo/lib/plugins/helper/partial.js:34:15)
2019-11-22T13:19:42.3534389Z at eval (/github/workspace/themes/indigo/layout/layout.ejs:10:17)
2019-11-22T13:19:42.3535202Z at layout (/github/workspace/node_modules/ejs/lib/ejs.js:682:17)
2019-11-22T13:19:42.3536218Z at Theme._View.View._compiled (/github/workspace/node_modules/hexo/lib/theme/view.js:123:48)
2019-11-22T13:19:42.3537189Z at Theme._View.View.View.render (/github/workspace/node_modules/hexo/lib/theme/view.js:29:15)
2019-11-22T13:19:42.3538186Z at /github/workspace/node_modules/hexo/lib/theme/view.js:40:23
2019-11-22T13:19:42.3539041Z at tryCatcher (/github/workspace/node_modules/bluebird/js/release/util.js:16:23)
2019-11-22T13:19:42.3540178Z at Promise._settlePromiseFromHandler (/github/workspace/node_modules/bluebird/js/release/promise.js:547:31)
2019-11-22T13:19:42.3541137Z at Promise._settlePromise (/github/workspace/node_modules/bluebird/js/release/promise.js:604:18)
2019-11-22T13:19:42.3542223Z at Promise._settlePromise0 (/github/workspace/node_modules/bluebird/js/release/promise.js:649:10)
2019-11-22T13:19:42.3543409Z at Promise._settlePromises (/github/workspace/node_modules/bluebird/js/release/promise.js:729:18)
2019-11-22T13:19:42.3544301Z at _drainQueueStep (/github/workspace/node_modules/bluebird/js/release/async.js:93:12)
2019-11-22T13:19:42.3545336Z at _drainQueue (/github/workspace/node_modules/bluebird/js/release/async.js:86:9)
2019-11-22T13:19:42.3546945Z at Async._drainQueues (/github/workspace/node_modules/bluebird/js/release/async.js:102:5)
2019-11-22T13:19:42.3549435Z at Immediate.Async.drainQueues [as _onImmediate] (/github/workspace/node_modules/bluebird/js/release/async.js:15:14)
2019-11-22T13:19:42.3551798Z at processImmediate (internal/timers.js:439:21)
2019-11-22T13:19:42.3564699Z ERROR Render HTML failed: posts/47780/index.html
2019-11-22T13:19:42.3565323Z TypeError: /github/workspace/themes/indigo/layout/layout.ejs:3
2019-11-22T13:19:42.3565929Z 1| <!DOCTYPE html>
2019-11-22T13:19:42.3566657Z 2| <html>
2019-11-22T13:19:42.3568922Z >> 3| <%- partial('_partial/head') %>
2019-11-22T13:19:42.3646615Z 4| <body>
2019-11-22T13:19:42.3647713Z 5| <%- partial('_partial/loading') %>
2019-11-22T13:19:42.3648479Z 6| <%- partial('_partial/menu') %>
2019-11-22T13:19:42.3648813Z
2019-11-22T13:19:42.3649446Z /github/workspace/themes/indigo/layout/_partial/head.ejs:51
2019-11-22T13:19:42.3650487Z 49| <%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
2019-11-22T13:19:42.3651212Z 50| <% if ((config.feed) && (config.feed.path.length)) { %>
2019-11-22T13:19:42.3653776Z >> 51| <link rel="alternate" type="application/atom+xml" title="<%= config.title %>" href="<%- url_for(config.feed.path) %>">
2019-11-22T13:19:42.3656209Z 52| <% } %>
2019-11-22T13:19:42.3658852Z 53| <%- favicon_tag(theme.favicon) %>
2019-11-22T13:19:42.3661486Z 54| <link rel="stylesheet" href="<%- url_for(theme_css('/css/style', cache)) %>">
And the version of my hexo
hexo: 4.0.0
hexo-cli: 3.1.0
os: Darwin 19.0.0 darwin x64
node: 13.1.0
v8: 7.8.279.17-node.19
uv: 1.33.1
zlib: 1.2.11
brotli: 1.0.7
ares: 1.15.0
modules: 79
nghttp2: 1.39.2
napi: 5
llhttp: 1.1.4
openssl: 1.1.1d
cldr: 35.1
icu: 64.2
tz: 2019a
unicode: 12.1
The config file
feed:
type: atom
path: atom.xml
limit: 20
hub:
content:
content_limit: 140
content_limit_delim: " "
order_by: -date
icon: icon.png
autodiscovery: false
I now see what's the issue, #96 converts config.feed.path
to array, which is incompatible with the theme's autodiscovery tag,
<link rel="alternate" type="application/atom+xml" title="<%= config.title %>" href="<%- url_for(config.feed.path) %>">
for now, a workaround is,
<link rel="alternate" type="application/atom+xml" title="<%= config.title %>" href="<%- url_for(config.feed.path[0]) %>">
A fix is incoming.
I previously only tested that PR with hexo-theme-typing which doesn't use url_for()
nor config.feed.path
,
<link rel="alternate" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
Created a workaround #114
@yrpang
Not part of this issue, but I notice a shortcoming of the theme you're using. The theme is not compatible with rss2.
For rss2 compatibility,
<% if ((config.feed) && (config.feed.type.length) && (config.feed.path.length)) { %>
<link rel="alternate" type="application/<%- config.feed.type.replace(/2$/, '') %>+xml" title="<%= config.title %>" href="<%- url_for(config.feed.path) %>">
<% } %>
Submitted a PR to the theme, yscoder/hexo-theme-indigo#489.
BTW, @curbengh I'm using hexo next theme. I see many people using rss with this theme
Here's what happened, as part of #96, for simpler code, config is converted from string to array. But the affected themes which uses config of this plugin (as part of their autodiscovery implementation) still expect it to be string. #114 is actually more of a workaround than a bugfix.
A theme should not expect a plugin's config to be consistent as a plugin's functionality may change over time. If a theme decides to use a plugin's config, then it is the theme's responsibility to check for compatibility and apply the necessary workaround to the theme. A plugin shouldn't be expected to check how a theme uses its config.
This issue adds to the necessity of #96 and demonstrate that the current recommendation of supporting rss in theme is never really a good idea. A theme's supposed enhancement to this plugin, ends up being this plugin having to support the theme.
Paging next theme dev @stevenjoezhang, hexojs/hexo-theme-unit-test#25 includes a code snippet on how a theme can support #96 while retaining compatibility with older versions (of this plugin).
#114 shouldn't be necessary if RSS support was made optional in the first place, but in fairness, this issue might not be foreseen at that time (of recommending rss support).