Hexo: After upgrading 4.2.0, it caused that generating html with hexo-pwa is failed

Created on 1 Jan 2020  ·  15Comments  ·  Source: hexojs/hexo

Check List

Please check followings before submitting a new issue.

  • [x] I have already read Docs page & Troubleshooting page
  • [x] I have already searched existing issues and they are not help to me
  • [x] I examined error or warning messages and it's difficult to solve
  • [x] Using the latest version of Hexo (run hexo version to check)
  • [x] Node.js is higher than 8.6.0

Expected behavior

hexo g is successful.

Actual behavior

hexo g is failed.

How to reproduce?

Using hexo-pwa plugin, then hexo g

Environment & Settings

Node.js & npm version

$ node -v
v13.3.0

$ npm -v
6.13.4

$ yarn -v
1.19.2

Hexo and Plugin version(npm ls --depth 0)

    "hexo": "4.2.0",
    "hexo-baidu-url-submit": "0.0.6",
    "hexo-deployer-git": "^2.1.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-baidu-sitemap": "^0.1.6",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-feed": "^2.2.0",
    "hexo-generator-index": "^1.0.0",
    "hexo-generator-searchdb": "^1.2.0",
    "hexo-generator-sitemap": "^2.0.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-helper-live2d": "^3.1.1",
    "hexo-pwa": "^0.1.3",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-server": "^1.0.0",
    "live2d-widget-model-koharu": "^1.0.5",
    "live2d-widget-model-z16": "^1.0.5",
    "npm-check-updates": "^4.0.1"

Others

FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
TypeError: Cannot read property 'data' of undefined
    at Hexo.module.exports (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\hexo-pwa\lib\serviceWorker.js:23:39)
    at Hexo.tryCatcher (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\util.js:16:23)
    at Hexo.<anonymous> (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\method.js:15:34)
    at C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\hexo\lib\hexo\index.js:390:22
    at tryCatcher (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\util.js:16:23)
    at MappingPromiseArray._promiseFulfilled (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\ma
p.js:68:38)
    at MappingPromiseArray.PromiseArray._iterate (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\releas
e\promise_array.js:115:31)
    at MappingPromiseArray.init (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\promise_array.j
s:79:10)
    at MappingPromiseArray._asyncInit (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\map.js:37
:10)
    at _drainQueueStep (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\async.js:97:12)
    at _drainQueue (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\async.js:86:9)
    at Async._drainQueues (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\release\async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\purpl\Desktop\caoyu.info\cc\node_modules\bluebird\js\re
lease\async.js:15:14)
    at processImmediate (internal/timers.js:444:21)

image

plugin question

Most helpful comment

Could you(hexo) @SukkaW fork the hexo-pwa, or create a new one? Then, maintain it by hexo official??? It seems that hexo-pwa is not maintained by lavas. I think PWA should be the basic for all hexo blogs. What do you think?

All 15 comments

After downgrading to 4.1.1, it works fine.

It could be caused by lodash, hexo-pwa is using lodash.

@mystic-cg

Locals.cache should only be considered as an Internal private API. After https://github.com/hexojs/hexo/commit/c6e6e6b4e79d04f48b73d66812ad5e601b0f651a#diff-8706ed85bcc456bc4bd99698f3cb949dR7 the Locals.cache is now Locals.cache.cache.

According to Hexo API's documents, there is already a method called Locals.toObject(). The developer should always using public API for consistency. Please open an issue at hexo-pwa and asking them for using Locals.toObject() instead of Locals.cache.

Related issue: https://github.com/tea3/hexo-related-popular-posts/pull/23

I have registered the new issue.
https://github.com/lavas-project/hexo-pwa/issues/15

Hi,

Just replace let posts = this.locals.cache.posts.data; and order lamba function (for convenience) by let posts = locals.posts.sort('-date').toArray();

Index: lib/serviceWorker.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/serviceWorker.js    (revision 05599aa1ec09e057c5d4c6f9376f8c642105a019)
+++ lib/serviceWorker.js    (date 1582969070298)
@@ -20,12 +20,7 @@
   let precacheUrls = (config.preload && config.preload.urls) || [];

   let postsCount = config.preload.posts;
-  let posts = this.locals.cache.posts.data;
-
-  // sort posts by publishing date
-  posts.sort(function (a, b) {
-    return a.date < b.date;
-  });
+  let posts = locals.posts.sort('-date').toArray();

   let post;
   for (let i = 0; i < posts.length && postsCount > 0; i++, postsCount--) {

Could you(hexo) @SukkaW fork the hexo-pwa, or create a new one? Then, maintain it by hexo official??? It seems that hexo-pwa is not maintained by lavas. I think PWA should be the basic for all hexo blogs. What do you think?

Would be great indeed to have hexo-pwa actively maintained. PWA is the defacto standard anyhow. I will try to fix as suggested somewhere soon.

Thanks a lot, @marcofranssen

See https://github.com/lavas-project/hexo-pwa/pull/16/files for the fix and some other improvement

@mystic-cg seems hexo-pwa isn't maintained. No response on the fix provided in my PR.

@marcofranssen I open a new issue #4250, hope hexo can maintain it or a new one.

This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@mystic-cg it's very quiet on this whole thingy. Any ideas on how we can move this forward?

@marcofranssen Personally, I hope the Hexo Official can maintain this project.

Could you(hexo) @SukkaW fork the hexo-pwa, or create a new one? Then, maintain it by hexo official??? It seems that hexo-pwa is not maintained by lavas. I think PWA should be the basic for all hexo blogs. What do you think?

Any ideas?
@SukkaW
@stevenjoezhang
@jiangtj
@curbengh

@mystic-cg

No. Currently we have no plan and willing to maintain this plugin.

The issue is now closed and locked.

Was this page helpful?
0 / 5 - 0 ratings