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

Regression in Node 14 #4260

Closed
curbengh opened this issue Apr 23, 2020 · 21 comments
Closed

Regression in Node 14 #4260

curbengh opened this issue Apr 23, 2020 · 21 comments
Projects
Milestone

Comments

@curbengh
Copy link
Contributor

curbengh commented Apr 23, 2020

Noticed this issue on my blog, Netlify doesn't upload any file after upgrading Node 14 (build log), and led to an empty site.

A working workaround is to downgrade; I downgraded to Node 12, my blog never had any issue with Node 13, so it looks like a Node 14 issue.

I can replicate this issue in hexojs/site#1395, site does become empty.


Replicated the issue in my workstation, with a dummy blog (default plugins only). /public folder has all the files, but they are all empty.

  • Install node_modules with Node 14, run Hexo with Node 14: ❌
  • Install node_modules with Node 13, run Hexo with Node 14: ❌
  • Install node_modules with Node 13, run Hexo with Node 13: ✅
  • Install node_modules with Node 14, run Hexo with Node 13: ✅

Node 13 is v13.13.0, Node 14 is v14.0.0

@hexojs/core


Tested packages:

hexo
hexo-fs
hexo-cli

warehouse
hexo-renderer-nunjucks
hexo-renderer-marked
hexo-util
hexo-generator-feed.


Edit (30 April 2020): fix released in hexo-util@2.0.0 and hexo-fs@3.0.0.

There are two options to temporarily fix compatibility issues with Node 14:

  1. Downgrade to Node 10 or 12. If you use .nvmrc as part of your CI workflow, you need to change the content to 10 or 12.
  2. If you prefer to use Node 14, force upgrade hexo-util and hexo-fs:
{
  ...
  "dependencies": {
    "hexo": "^4.0.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-index": "^1.0.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-stylus": "^1.1.0",
    "hexo-renderer-marked": "^2.0.0",
    "hexo-server": "^1.0.0",
+    "hexo-util": "^2.1.0",
+    "hexo-fs": "^3.0.1"
  }
}
$ rm -rf node_modules/
$ npm install
@yoshinorin
Copy link
Member

yoshinorin commented Apr 23, 2020

In Node.js v14 the hexo-util@ChachStream.getCache returns an empty array.

Node.js v14 has many changes about stream. I think this issue caused by these changes.

@yoshinorin
Copy link
Member

OK. I found this document transform.destroy([error])

Implementors should not override this method, but instead implement readable._destroy(). The default implementation of _destroy() for Transform also emit 'close' unless emitClose is set in false.

But, hexo-util@ChachStream seems override destory method. Is this correct?

@curbengh
Copy link
Contributor Author

Node.js v14 has many changes about stream. I think this issue caused by these changes.

I looked around the https://github.com/nodejs/node PRs, the stream changes already included on Node 13, but all hexo-related packages have no issue with it.

@jiangtj
Copy link
Member

jiangtj commented Apr 24, 2020

#4257 This problem is also caused by v14

@SukkaW
Copy link
Member

SukkaW commented Apr 24, 2020

It seems that all problem is related with hexo-fs:

  • hexo-cli failed the init test.
  • hexo failed the writeFIle, watch and publish, which is also related with fs.

@stevenjoezhang
Copy link
Member

Yes, it seems that most of the error messages come from this commit

nodejs/node@a13500f#diff-0034beae2e92ed0b59570df638dda305

@SukkaW
Copy link
Member

SukkaW commented Apr 24, 2020

The fix has already implemented in hexojs/hexo-fs#60

@curbengh curbengh added this to the 5.0.0 milestone Apr 24, 2020
@curbengh curbengh added this to To do in 5.0.0 via automation Apr 24, 2020
@curbengh curbengh moved this from To do to In progress in 5.0.0 Apr 24, 2020
@stevenjoezhang
Copy link
Member

Tests show that cacheStream.destroys in Node.js 14 will be triggered twice, which causes all content to be empty.
Renaming these two destroy methods can solve the problem.

https://github.com/hexojs/hexo-util/blob/31f74a5296d74339b76909a05ee38d8bb38560bf/lib/cache_stream.js#L21

cacheStream.destroy();

@curbengh
Copy link
Contributor Author

curbengh commented Apr 24, 2020

OK. I found this document transform.destroy([error])

Implementors should not override this method, but instead implement readable._destroy(). The default implementation of _destroy() for Transform also emit 'close' unless emitClose is set in false.

But, hexo-util@ChachStream seems override destory method. Is this correct?

Tests show that cacheStream.destroys in Node.js 14 will be triggered twice, which causes all content to be empty.
Renaming these two destroy methods can solve the problem.

What if the following lines are removed so that cacheStream.destroy() is equivalent to Transform.destroy()?

https://github.com/hexojs/hexo-util/blob/31f74a5296d74339b76909a05ee38d8bb38560bf/lib/cache_stream.js#L21-L23


hexojs/hexo-util#195

@curbengh
Copy link
Contributor Author

Since the fixes won't be backported to Hexo 4, I suggest to add { "engines" : { "node" : ">=8.10.0 <14" } } to Hexo 4.2.1. Note that recent npm versions will only show warning but doesn't stop installation in incompatible Node.

If user wants to go ahead with Hexo 4 + Node 14, the fix is to install hexo-util v2 and hexo-fs v3.

@SukkaW
Copy link
Member

SukkaW commented Apr 25, 2020

@curbengh

I suggest to add { "engines" : { "node" : ">=8.10.0 <14" } } to Hexo 4.2.1

However there are already many features merged into master branch. Should we released a 4.3.0. though?

@LeoEatle
Copy link

I met the same issue.
Now I change travis.yml to

node_js: 13.2.0

@curbengh
Copy link
Contributor Author

curbengh commented Apr 30, 2020

However there are already many features merged into master branch. Should we released a 4.3.0. though?

I mean a single patch on top of c0bf222 tagged with 4.2.0. See #4285.

Other merged changes on top of that commit should be part of 5.0.0, I think some breaking changes are already merged.

@stevenjoezhang
Copy link
Member

@luisleee circular dependencies are caused by stylus, not Hexo.

@rapiz1
Copy link

rapiz1 commented May 8, 2020

When will a version compatible with node 14 release?

@dumindu
Copy link

dumindu commented May 9, 2020

I tried even with old node versions like v12 but still facing issues. Can't we release a hot fix for this?

@yangxyo
Copy link

yangxyo commented May 12, 2020

I tried even with old node versions like v12 but still facing issues. Can't we release a hot fix for this?
Please run:

node --version

to show your node version.

@dumindu
Copy link

dumindu commented May 12, 2020

@yangxyo Tried both v12.5.0 and v12.16.3 as well. It generates empty files with partial template block codes. You can try https://github.com/hexojs/site

@luisleee
Copy link

luisleee commented May 13, 2020

@dumindu You can reinstall it. It can work on v12.16.3 on my machine.

@dumindu
Copy link

dumindu commented May 13, 2020

Oops, my mistake. Looks like my current issue is due to hexojs/site#1410 . Fixed. Thanks everyone :)

@yoshinorin
Copy link
Member

yoshinorin commented May 14, 2020

@LeoEatle @rapiz1 @dumindu @yangxyo @luisleee

We published v4.2.1.
v4.2.1 has included fixed compatible with Node 14.

Thanks :)

5.0.0 automation moved this from In progress to Done May 14, 2020
@SukkaW SukkaW unpinned this issue Jun 13, 2020
@SukkaW SukkaW pinned this issue Jun 13, 2020
@curbengh curbengh unpinned this issue Aug 10, 2020
lotem added a commit to rime/home that referenced this issue Dec 22, 2020
lotem added a commit to rime/home that referenced this issue Dec 22, 2020
lotem added a commit to rime/home that referenced this issue Dec 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
5.0.0
  
Done
Development

No branches or pull requests

10 participants