- Version:
v12.1.0, although seems to apply to older versions too
- Platform:
macOS
- Subsystem:
inspector or vm
Demonstrating the issue from the title:
const inspector = require('inspector')
const vm = require('vm')
const session = new inspector.Session()
session.connect()
const ctx = vm.createContext({
a: 100
})
a = 100
session.post('Runtime.evaluate', {
expression: 'a',
throwOnSideEffect: true,
contextId: 2 // ctx's id
}, (error, res) => {
console.log(res)
if (
res.exceptionDetails &&
res.exceptionDetails.exception.description.startsWith('EvalError: Possible side-effect')
) {
process.exit(1)
}
})
^ exits with code 1, even though the provided expression a is clearly causing no side effect.
Weirdly enough, changing the contextId from 2 to 1 (1 being the global one) makes the snippet exit with 0, hence working as expected.