-
-
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
ava test framework with worker threads - Module did not self-register #3164
Comments
Did you try |
@lovell Thanks for prompt reply. Just realised it might be due to that, so I am about to issue a deploy without worker threads. If this is the case, my next question would be: how can I have ava with multiple worker threads to work with Sharp? |
Yes, it actually fixed it. |
https://sharp.pixelplumbing.com/install#worker-threads
You'll need to work out how to inject your own logic into ava's main thread. Alternatively, use a musl-based Linux such as Alpine, which sensibly ignores Node.js' attempt to call |
I've slightly expanded the existing docs about this via commit d0c8e95 |
Awesome, thanks! |
* rm test of bin/nft-ttr cli func * .github/workflows/cron.yml runs on all PRs, not just those targeting main * configure ava not to use worker threads (sharp compat lovell/sharp#3164)
You can also do this as a better workaround (save this as const isCI = require('is-ci');
module.exports = {
workerThreads: !isCI
}; |
Thanks @titanism that's a neat solution. Given this is primarily due to a feature of glibc-based Linux, a possible alternative might be something like: const { familySync, GLIBC } = require('detect-libc');
module.exports = {
workerThreads: familySync() !== GLIBC
}; |
In my case I needed worker threads to use AVA's shared workers. Just requiring the module in the config file for AVA: // ava.config.js
require("sharp");
// ... worked for me. |
The forthcoming libvips v8.13.0, which will ship with the forthcoming sharp v0.31.0, should remove the need for all these workarounds - see libvips/libvips#2934 |
Hi there @lovell per forwardemail/forwardemail.net@5460f9a we updated to latest version v0.32.1 and the error still persists with worker threads. This issue is still not resolved. Please re-open or update the worker threads docs at https://sharp.pixelplumbing.com/install#worker-threads to suggest the following workaround: npm install detect-libc // ava.config.js
const { familySync, GLIBC } = require('detect-libc');
module.exports = {
// <https://github.com/lovell/sharp/issues/3164>
workerThreads: familySync() !== GLIBC
}; |
@titanism As of sharp v0.31.0 this should no longer be a problem. Are you able to verify if the removal of this line still allows your tests to pass? https://github.com/forwardemail/forwardemail.net/blob/748b21304ec5224d14ab5b98e7dc0e51ad96b72f/ava.config.js#L10 |
Hello, Adding |
@lovell |
Actually @lovell I stand corrected, this is a bug and is still not working. |
Same error: 2024-07-19T17:27:17.7673481Z Uncaught exception in test/caldav/index.js
2024-07-19T17:27:17.7674145Z
2024-07-19T17:27:17.7674430Z test/caldav/index.js:20
2024-07-19T17:27:17.7674874Z
2024-07-19T17:27:17.7680687Z 19:
2024-07-19T17:27:17.7682003Z 20: const utils = require('../utils');
2024-07-19T17:27:17.7683032Z 21: const CalDAV = require('../../caldav-server');
2024-07-19T17:27:17.7683608Z
2024-07-19T17:27:17.7684830Z Error:
2024-07-19T17:27:17.7685536Z Something went wrong installing the "sharp" module
2024-07-19T17:27:17.7686116Z
2024-07-19T17:27:17.7687860Z Module did not self-register: '/home/runner/work/forwardemail.net/forwardemail.net/node_modules/.pnpm/[email protected]/node_modules/sharp/build/Release/sharp-linux-x64.node'.
2024-07-19T17:27:17.7689444Z
2024-07-19T17:27:17.7689765Z Possible solutions:
2024-07-19T17:27:17.7690928Z - Using worker threads? See https://sharp.pixelplumbing.com/install#worker-threads
2024-07-19T17:27:17.7692922Z - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
2024-07-19T17:27:17.7695422Z - Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp"
2024-07-19T17:27:17.7697253Z - Consult the installation documentation: https://sharp.pixelplumbing.com/install
2024-07-19T17:27:17.7698100Z |
@lovell not working in |
No big deal though btw, we have no problem using |
If possible please can you try v0.33.0+ as the final piece of the puzzle was added via commit 4a37a27 |
Done per forwardemail/forwardemail.net@22d5c04, waiting on build to finish. |
Ah, it requires a Node engine change: Error: Could not load the "sharp" module using the darwin-arm64 runtime
Possible solutions:
- Please upgrade Node.js:
Found 18.16.0
Requires ^18.17.0 || ^20.3.0 || >=21.0.0 Going to try to get this sorted out and report back. |
It works @lovell !!!! ✅ https://github.com/forwardemail/forwardemail.net/actions/runs/10013293960/job/27680579340 (passing) ![]() |
Possible bug
I've been noticing this is quite a normal error message to receive, but most of the suggestions recommend deleting node_modules, or similar - which is not really relevant in my case, since the error only happens during a Github Actions deployment.
My github actions step looks something like this:
npm install --platform=linux --ignore-scripts=false --arch=x64 sharp
afternpm ci
but it will give me the same error.package-lock.json
to see if that would make a difference during deployment, but to no avail.npm install --platform=linux --arch=x64 --verbose sharp
in the github actions runner: https://gist.github.com/simplenotezy/bb1dc5fa506c8629c03d80703247969eI am not really sure how to proceed here.
Not sure if it is related to worker threads (https://sharp.pixelplumbing.com/install#worker-threads). The error does occur when running my tests, which I believe could be multi-threaded (Using Ava 4)
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.node -e "require('sharp')"
completes without error.Are you using the latest version of sharp?
sharp
as reported bynpm view sharp dist-tags.latest
.What is the output of running
npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?What is the expected behaviour?
Should install without errors
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
This happens during my Github Actions deployment, of a Nest.js framework that uses Sharp.
Please provide sample image(s) that help explain this problem
The text was updated successfully, but these errors were encountered: