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

Cache directory should account for architecture #36

Open
sirreal opened this issue May 10, 2021 · 0 comments
Open

Cache directory should account for architecture #36

sirreal opened this issue May 10, 2021 · 0 comments

Comments

@sirreal
Copy link

sirreal commented May 10, 2021

The compile cache may cause Node to crash if it was generated from a Node build where os.arch() does not match.

I experienced that recently with Node 16 on an Apple M1 machine. I was debugging an issue with yarn and eventually tracked the issue to v8-compile-cache.
yarn had been used with a non-native Node build (os.arch() reported x86), then when a native M1 build of the same node version was installed (os.arch() reported arm64) Node would crash when invoking yarn.

We determined that a compile cache had been generated, but because the compile cache matched independent of the architecture it was incompatible when used across Node binaries —both valid and running on the same machine without issue— and would cause Node to crash.

We were able to resolve the issue by:

  • Invoking yarn with the environment variable as follows: DISABLE_V8_COMPILE_CACHE=1 yarn
  • Finding and removing the generated temporary directories that look like v8-compile-cache*

I believe an appropriate solution would be to add os.arch() to the cache directories around here:

const version = typeof process.versions.v8 === 'string'
? process.versions.v8
: typeof process.versions.chakracore === 'string'
? 'chakracore-' + process.versions.chakracore
: 'node-' + process.version;
const cacheDir = path.join(os.tmpdir(), dirname, version);

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

No branches or pull requests

1 participant