Open Bug 1603575 Opened 4 years ago Updated 2 years ago

[jsdbg2] Debugger cannot follow cross-compartment promise resolutions

Categories

(Core :: JavaScript Engine, enhancement, P2)

enhancement

Tracking

()

People

(Reporter: jimb, Unassigned)

References

(Blocks 1 open bug)

Details

If we resolve a promise P1 to another promise P2 (such that resolving P2 resolves P1 in the same way), and the two promises are in different compartments, the Debugger API does not provide enough information to recover P1 from P2's reaction records.

I think this means that Debugger will not be able to include an async function's awaiter in the stack trace if the promise being awaited is in a different compartment than the the awaiting function.

Cross-compartment promise resolution as described above produces a reaction record like that used for a call to then or catch, with internal resolve and reject functions with extended slots referring to P1. Debugger.Object.prototype.getReactionRecords lets us recover the functions, but we have no way to recognize these internal functions and retrieve their internal slots.

Possible solutions:

  • Debugger could acquire methods and accessors for recognizing such functions and retrieving the value of their internal slots.

  • PromiseObject::forEachReactionRecord could recognize such internal functions, retrieve the promise they will resolve, and present it to the PromiseReactionRecordBuilder callback object directly. Then D.O.p.getReactionRecords could include it as an additional property of the object used to represent the reaction record.

See Also: → 1592427
Priority: -- → P2

I'm not sure how often these situations will arise in practice. It seems like, with fission, each process should be same-origin, and same-origin realms can share a compartment now, so compartments should only serve to separate chrome and content. And I don't see when chrome is going to attach reactions to content promises, or vice versa.

But I am not at all sure about this.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.