Skip to content

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

@JonasBa

Description

@JonasBa

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions