-
-
Notifications
You must be signed in to change notification settings - Fork 562
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
Promise.withResolvers() returned object had resolve and reject functions swapped #1983
Promise.withResolvers() returned object had resolve and reject functions swapped #1983
Conversation
So much joy seeing quality PRs popping up! |
Is the PR Check / windows still a bit flaky or did I actually break something? 😆 |
Looks like a failed test:
|
Hm, interesting. I am currently continuously keep that test running locally (windows machine) and it rejects to fail - everything stays green 🤔. Can you just re-run the PR check again to see if it actually fails again? |
After trying to understand the test, I would say: that's a flaky one and it's failure is not a result of the changes above. Code coverage for that test shows that it doesn't touch any promise related code. In addition, the test uses Change this failing test is not that difficult, but I would rather do that in a separate PR because it is quite unrelated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, thank you! Weird that test262 suite didn't cover this..
When using
Promise.withResolvers()
, the returned object hadresolve
andreject
swapped. Meaning thatdid return a rejected promise.
and
dir return a resolved promise.
The fix: The record
PromiseCapability
had the following property orderThe method
PromiseConstructor.NewPromiseCapability()
however flipped the two last properties when calling the PromiseCapability constructor.Refactoring: In addition to fix the parameter order in
PromiseConstructor.NewPromiseCapability()
, I had to change two methods, which already relied on the flipped assignment: "Promise.race" and "Promise.all". While deconstruction can be nice, I think that the deconstruction usage ofPromiseCapability
might be a reason that this flip was not caught earlier. So:_
variables, I directly usePromiseInstance.[Property]
, which makes it easier to spot mistakesPromiseCapability
to keep the order consistent.