Skip to content

Realm to use for promises #932

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
annevk opened this issue Oct 15, 2020 · 4 comments
Open

Realm to use for promises #932

annevk opened this issue Oct 15, 2020 · 4 comments

Comments

@annevk
Copy link
Member

annevk commented Oct 15, 2020

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.

@domenic
Copy link
Member

domenic commented Oct 15, 2020

In my opinion, promises do not need any special treatment here. So I think this just reduces to #135.

@annevk
Copy link
Member Author

annevk commented Oct 15, 2020

@domenic that's fair, but I think that still leaves exceptions getting wrapped in promises that end up using the current realm.

@domenic
Copy link
Member

domenic commented Oct 15, 2020

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.

@karlt
Copy link

karlt commented Oct 19, 2020

A key difference with the relevant realm is when it involves a discarded browsing context and awaiting the promise will never resume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants