Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After upgrading 4.2.0, it caused that generating html with hexo-pwa is failed #4044

Closed
5 tasks done
pplmx opened this issue Jan 1, 2020 · 15 comments
Closed
5 tasks done
Labels
plugin question

Comments

@pplmx
Copy link

@pplmx pplmx commented Jan 1, 2020

Check List

Please check followings before submitting a new issue.

  • I have already read Docs page & Troubleshooting page
  • I have already searched existing issues and they are not help to me
  • I examined error or warning messages and it's difficult to solve
  • Using the latest version of Hexo (run hexo version to check)
  • 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

@pplmx
Copy link
Author

@pplmx pplmx commented Jan 1, 2020

After downgrading to 4.1.1, it works fine.

@pplmx
Copy link
Author

@pplmx pplmx commented Jan 1, 2020

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

@SukkaW
Copy link
Member

@SukkaW SukkaW commented Jan 1, 2020

@mystic-cg

Locals.cache should only be considered as an Internal private API. After c6e6e6b#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: tea3/hexo-related-popular-posts#23

@pplmx
Copy link
Author

@pplmx pplmx commented Jan 2, 2020

I have registered the new issue.
lavas-project/hexo-pwa#15

@mnusan
Copy link

@mnusan mnusan commented Feb 29, 2020

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--) {

@pplmx
Copy link
Author

@pplmx pplmx commented Mar 10, 2020

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?

pplmx referenced this issue in lavas-project/hexo-pwa Mar 23, 2020
* Fix post sorting so latest posts are precached

* Format code and add prettierrc config

* Update sw-toolbox to latest version
@marcofranssen
Copy link
Contributor

@marcofranssen marcofranssen commented Mar 25, 2020

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.

@pplmx
Copy link
Author

@pplmx pplmx commented Mar 25, 2020

Thanks a lot, @marcofranssen

@marcofranssen
Copy link
Contributor

@marcofranssen marcofranssen commented Mar 25, 2020

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

@marcofranssen
Copy link
Contributor

@marcofranssen marcofranssen commented Apr 17, 2020

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

@pplmx
Copy link
Author

@pplmx pplmx commented Apr 18, 2020

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

@stale
Copy link

@stale stale bot commented Jun 17, 2020

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.

@stale stale bot added the stale label Jun 17, 2020
@marcofranssen
Copy link
Contributor

@marcofranssen marcofranssen commented Jun 17, 2020

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

@stale stale bot removed the stale label Jun 17, 2020
@pplmx
Copy link
Author

@pplmx pplmx commented Jun 18, 2020

@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

@SukkaW
Copy link
Member

@SukkaW SukkaW commented Jun 18, 2020

@mystic-cg

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

The issue is now closed and locked.

@SukkaW SukkaW closed this as completed Jun 18, 2020
@hexojs hexojs locked as resolved and limited conversation to collaborators Jun 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin question
Projects
None yet
Development

No branches or pull requests

4 participants