Open Bug 1518316 Opened 6 years ago Updated 2 years ago

[jsdbg2] Microtasks enqueued during an eval from a Debugger hook will cause DebuggeeWouldRun exceptions

Categories

(Core :: JavaScript Engine, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: jimb, Unassigned)

References

(Blocks 2 open bugs)

Details

Microtasks enqueued by debuggee code called from a Debugger invocation function will get run as part of the next microtask checkpoint, but in typical use, that checkpoint will take place in a debuggee NoExecute region, and elicit a DebuggeeWouldRun exception.

For example, if content hits a breakpoint, and the developer evaluates Promise.resolve(42).then(() => console.log("boo")), the next microtask checkpoint after that eval will probably take place when the event handler that delivered the eval request to the debug server returns. That event is probably being delivered within a nested event loop spun by the debugger user interface while paused at the breakpoint, within the scope of an EnterDebuggeeNoExecute, so the attempt to run the promise reaction job will fail with a DebuggeeWouldRun exception - or would, if those were enabled.

Off-the-cuff API sketch: dbg.withFreshMicrotaskQueueAndCheckpoint(() => do lots of evals), to 1) stash the current queue, 2) install a fresh one, 3) call the function, 4) perform a microtask checkpoint, 5) restore the stashed queue.

Blocks: dbg-r2c
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.