Skip to content

inspector: Runtime.evaluate with throwOnSideEffect & contextId of vm.createContext throws when it shouldn't #27518

@rsify

Description

@rsify
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    inspectorIssues and PRs related to the V8 inspector protocol

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions