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

worker threads: sharp fails to register after first test run #3268

Closed
3 tasks done
JonasBa opened this issue Jun 17, 2022 · 4 comments
Closed
3 tasks done

worker threads: sharp fails to register after first test run #3268

JonasBa opened this issue Jun 17, 2022 · 4 comments
Labels

Comments

@JonasBa
Copy link

JonasBa commented Jun 17, 2022

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

Problem:
I have a use case where we are using worker threads to run multiple image diffing operations which in the end use sharp to compose the final image. Everything is working as expected and I started adding integration tests that run in CI and I am seeing that any test ran after the first from the suite fails with

Worker error Error: 
    Something went wrong installing the "sharp" module
    Module did not self-register: '/home/runner/work/action-visual-snapshot/action-visual-snapshot/node_modules/sharp/build/Release/sharp-linux-x64.node'.
    Possible solutions:
    - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
    - Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp"
    - Consult the installation documentation: https://sharp.pixelplumbing.com/install
        at Object.<anonymous> (/home/runner/work/action-visual-snapshot/action-visual-snapshot/node_modules/sharp/lib/sharp.js:31:9)
        at Module._compile (node:internal/modules/cjs/loader:1105:14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
        at Module.load (node:internal/modules/cjs/loader:981:32)
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
        at Module.require (node:internal/modules/cjs/loader:1005:19)
        at require (node:internal/modules/cjs/helpers:[102](https://github.com/getsentry/action-visual-snapshot/runs/6939020227?check_suite_focus=true#step:6:103):18)
        at Object.<anonymous> (/home/runner/work/action-visual-snapshot/action-visual-snapshot/node_modules/sharp/lib/constructor.js:8:1)
        at Module._compile (node:internal/modules/cjs/loader:1[105](https://github.com/getsentry/action-visual-snapshot/runs/6939020227?check_suite_focus=true#step:6:106):14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:[115](https://github.com/getsentry/action-visual-snapshot/runs/6939020227?check_suite_focus=true#step:6:116)9:10)

When running the same suite on M1 machine, the error is not present and test suite runs fine (I triple checked that each test does indeed call sharp), but this is not the case in CI, where the first test that calls sharp succeeds and all consecutive tests fail.

The only thing that is happening between the test runs is that we terminate each of the worker threads that process images, but there are no side effects which would cause the library to suddenly not be registered anymore. I have confirmed this by selecting different tests from the suite (using it.only) and they all pass individually, but fail once a new test is added.

Any pointers into what we could be doing wrong are very helpful and thank you for maintaining an awesome library

@JonasBa JonasBa added the triage label Jun 17, 2022
@lovell
Copy link
Owner

lovell commented Jun 17, 2022

@lovell lovell added question and removed triage labels Jun 17, 2022
@JonasBa
Copy link
Author

JonasBa commented Jun 17, 2022

@lovell I had not, and not sure how I missed it (I think I was too focused thinking it's an installation problem). It works as intended now -> I will post about this in some of the discussions that I've seen around in hopes that it helps someone else.

I sincerely appreciate your quick comment and the work that you are doing to maintain the project and it's community, is there a place where I can maybe send you a small donation to? Also, do you mind if I open a PR that adds a small note to that error message that may point people to ^?

@lovell
Copy link
Owner

lovell commented Jun 21, 2022

I've added a link to the worker thread docs in the error message when this condition it detected - see commit 853a203

@JonasBa
Copy link
Author

JonasBa commented Jun 21, 2022

💯 Thank you very much @lovell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants