Failing tests on node 20 + problem with global namespace
Hello there,
First of all, thank you for a great package!
We are currently on node 18 and I am looking at moving the the project I am working in over to node 20. I have encountered a few problems and could really need some pointers to understand what I am doing wrong.
My system looks like this:
Linux 5.15.0-70-generic #77~20.04.1-Ubuntu SMP Wed Apr 5 09:38:34 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
node v20.4.0
isolated-vm: v4.5.0-1-gab17bf6
I slightly modified the package.json:
"test": "node --no-node-snapshot test.js"
Running the test suite get 2 failing tests:
- microtask-timeout.js - this test runs forever and never exits
- snapshot.js - gives the following output:
snapshot.js: *fail*
code: 1 signal: null
stderr: node:internal/process/esm_loader:46
internalBinding('errors').triggerUncaughtException(
^
AssertionError [ERR_ASSERTION]: "'" == 'è'
at Object.<anonymous> (/home/ulrik/github/isolated-vm/tests/snapshot.js:29:9)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at require$$0.Module._extensions..js (/home/ulrik/github/isolated-vm/.pnp.cjs:6763:33)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at require$$0.Module._load (/home/ulrik/github/isolated-vm/.pnp.cjs:6610:31)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:165:29)
at ModuleJob.run (node:internal/modules/esm/module_job:192:25)
at async CustomizedModuleLoader.import (node:internal/modules/esm/loader:228:24) {
generatedMessage: true,
code: 'ERR_ASSERTION',
actual: "'",
expected: 'è',
operator: '=='
}
In our project we create a small runtime where we expose the lodash package as a global symbol: _. This is the output from the test:
1) Script tests
Malicious code
does not allow state to be permanently changed:
ReferenceError: _ is not defined
at stateChanger (<isolated-vm>:5:5)
at (<isolated-vm boundary>)
Changing the symbol name to something that is longer than 1 character fixes the problem.
Any hints about what I am doing wrong or ideas on how to fix any of these issues would be greatly appreciated.
Are you using createSnapshot? I can't recommend the snapshot feature anymore, this seems to be totally broken on v8's end except for the case of very controlled host libraries. Instead I would recommend using cachedData