Open annevk opened 4 years ago
In my opinion, promises do not need any special treatment here. So I think this just reduces to #135.
@domenic that's fair, but I think that still leaves exceptions getting wrapped in promises that end up using the current realm.
Yeah, that's part of why I've discouraged specs from throwing exceptions... I guess we could just as easily wrap them in the relevant realm of this.
A key difference with the relevant realm is when it involves a discarded browsing context and await
ing the promise will never resume.
I think we should give more advice to specifications how to deal with promises and realms.
I think typically promises are created in the relevant realm of this.
However, this might lead to inconsistencies for immediately rejected promises depending on how they are implemented. Implementations might rely on throwing being tackled by the IDL layer, which would use the current realm for such rejected promises.
Given what we have, the simplest advice to me would be that for promise-returning methods you throw in the synchronous section and let IDL deal with it, and create a promise in the relevant realm of this that you return at the end of the synchronous section (and operate on in the in parallel part).
This is fairly subjective though so I would love to hear other perspectives.