Skip to content
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

Use PromiseResolve and PerformPromiseThen directly #25

Open
petamoriken opened this issue Oct 25, 2022 · 3 comments
Open

Use PromiseResolve and PerformPromiseThen directly #25

petamoriken opened this issue Oct 25, 2022 · 3 comments

Comments

@petamoriken
Copy link

petamoriken commented Oct 25, 2022

The current draft uses methods like %Promise.all% directly and is not resistant to rewriting Promise.resolve or Promise.prototype.then.

const originalThen = Promise.prototype.then;
Promise.prototype.then = function () { console.log("bang!"); originalThen.apply(this, arguments) };

// bang!
await.all [new Promise((r) => r("foo"))];

I would like to suggest using PromiseResolve and PerformPromiseThen instead like the await operator, so that it can be worked with in Node.js and Deno's internal code.

FYI: denoland/deno#16196

@zloirock
Copy link

zloirock commented Oct 25, 2022

Passed to await.all promises can be third-party and PerformPromiseThen will not work with them - all such features work by thenable protocol.

@ljharb
Copy link
Member

ljharb commented Oct 25, 2022

Indeed it should be as robust as await.

@ljharb
Copy link
Member

ljharb commented Oct 25, 2022

However, it’s far too early for anyone to implement this proposal - until stage 3 - and the spec text won’t be finalized until stage 2 - so there’s time to adjust it.

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

No branches or pull requests

3 participants