-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Doesn't work with worker_threads #2263
Comments
Hi, you'll need to ensure you Shared libraries are opened via By requiring sharp in your main thread, you ensure the reference counter for all of its dependencies will always be at least 1, ensuring |
You can watch shared libraries opening "init" and closing "fini" as a program runs using: LD_DEBUG=files G_DEBUG=fatal-warnings node index.js 2>&1 | egrep "calling (init|fini)" |
Thanks, requiring sharp in the main thread does delay the closing to the end of execution, as you say. Any benefit of adding this information to the documentation? I noticed that there is no such problem on Alpine Linux (using musl libc). |
Docs updated via commit c91373f, thanks for the suggestion. The https://wiki.musl-libc.org/functional-differences-from-glibc.html#Unloading_libraries |
This suggestion is working for me too, unless the worker is terminated while converting an svg to a png and saving the png: await sharp(Buffer.from(svgString))
.toFile(fnPng) If the main thread terminates the worker while the worker is executing the line above, then the entire main thread crashes with this:
I'm hoping you might recognize this error and know what I'm doing wrong. If you need me to provide code to reproduce this, or open a new issue, I would be happy to do that. |
@ericman314 You should not terminate in-flight worker threads where native modules are involved. See nodejs/node#34567 for more context, which includes the recent addition of experimental (N-)APIs to Node.js that we won't be able to use until at least Node.js 10 reaches EOL, possibly later. |
When running with worker threads, terminating a previous thread and trying to
require('sharp')
in a new worker thread again I'm getting the following output:Are you using the latest version? Is the version currently in use as reported by
npm ls sharp
the same as the latest version as reported bynpm view sharp dist-tags.latest
?Yes
What are the steps to reproduce?
https://github.com/Ugzuzg/sharp-worker-threads
Run
node index.js
What is the expected behaviour?
sharp works with
worker_threads
.Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?
https://github.com/Ugzuzg/sharp-worker-threads
It has a dependency on
threads
which usesworker_threads
internally.Are you able to provide a sample image that helps explain the problem?
No image required.
What is the output of running
npx envinfo --binaries --system
?The text was updated successfully, but these errors were encountered: