-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
Cannot be used in Worker threads (Node 10.x) #204
Comments
This works around isaacs/node-graceful-fs#204, where `graceful-fs` cannot be loaded from within `Worker` threads. Since the language generators are loaded in worker threads whenever they are available, they cannot use `fs-extra` which itself uses `graceful-fs`. This is hopefully a temporary measure, until isaacs/node-graceful-fs#205 is merged & released.
This works around isaacs/node-graceful-fs#204, where `graceful-fs` cannot be loaded from within `Worker` threads. Since the language generators are loaded in worker threads whenever they are available, they cannot use `fs-extra` which itself uses `graceful-fs`. This is hopefully a temporary measure, until isaacs/node-graceful-fs#205 is merged & released. --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
What version of node.js does this effect? In my tests |
At least in
Although the same note still stands on the latest release, although it appears to be defined there: /// worker-demo.js
const { Worker, isMainThread, parentPort } = require('worker_threads');
if (isMainThread) {
const worker = new Worker(__filename);
worker.on('message', ({ chdir }) => console.error(`(${process.version}) process.chdir is a ${chdir}`))
} else {
parentPort.postMessage({ chdir: typeof process.chdir });
} $ /usr/local/opt/node@10/bin/node --experimental-worker worker-demo.js
(v10.23.2) process.chdir is a undefined
$ /usr/local/opt/node@12/bin/node --experimental-worker worker-demo.js
(v12.20.1) process.chdir is a function |
isaacs/node-graceful-fs#204 prevents `graceful-fs` (a dependency of `fs-extra`) from loading in a worker thread when using node < 12. The issue affects only version `4.2.5`, so pinning both `jsii-rosetta` and `jsii-pacmak` (both of which may use worker threads when available) to the last known good version: `4.2.4`, until a fixed release of `graceful-fs` is released.
…2554) isaacs/node-graceful-fs#204 prevents `graceful-fs` (a dependency of `fs-extra`) from loading in a worker thread when using node < 12. The issue affects only version `4.2.5`, so pinning both `jsii-rosetta` and `jsii-pacmak` (both of which may use worker threads when available) to the last known good version: `4.2.4`, until a fixed release of `graceful-fs` is released.
Thanks for the quick fix on this issue. I encountered it as well, it was preventing my Electron app from starting in node 10.20.1. The fix merged in this PR is the correct strategy, but I had luck launching my app with this small stop-gap that swallows the error... Use at your own risk.
|
The module cannot be loaded within a Worker thread, as
process.chdir
is not available (undefined
) in there. The following line causes aTypeError: Object prototype may only be an Object or null: undefined
:node-graceful-fs/polyfills.js
Line 22 in feedd03
I reckon the solution would be to have
graceful-fs
also not providechdir
in this scenario.The text was updated successfully, but these errors were encountered: