-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(zone.js): Promise.resolve(subPromise) should return subPromise #53423
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alan-agius4
approved these changes
Dec 7, 2023
devversion
reviewed
Dec 7, 2023
JiaLiPassion
force-pushed
the
promise-resolve
branch
2 times, most recently
from
December 7, 2023 14:21
660838b
to
d31bdc1
Compare
alan-agius4
added
area: zones
target: patch
This PR is targeted for the next patch release
labels
Dec 7, 2023
alan-agius4
added
the
action: global presubmit
The PR is in need of a google3 global presubmit
label
Dec 7, 2023
JiaLiPassion
force-pushed
the
promise-resolve
branch
2 times, most recently
from
December 11, 2023 01:13
3ceb3d4
to
a2a89a5
Compare
In the original `Promise` impelmentation, zone.js follow the spec from https://promisesaplus.com/#point-51. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // false ``` in this case, `p2` should be the same status with `p1` but they are still different instances. And for some edge case. ``` class MyPromise extends Promise { constructor(sub) { super((res) => res(null)); this.sub = sub; } then(onFufilled, onRejected) { this.sub.then(onFufilled, onRejected); } } const p1 = new Promise(setTimeout(res), 100); const myP = new MyPromise(p1); const r = await myP; r === 1; // false ``` So in the above code, `myP` is not the same instance with `p1`, and since `myP` is resolved in constructor, so `await myP` will just pass without waiting for `p1`. And in the current `tc39` spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolve `Promise.resolve(subP)` should return `subP`. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // true ``` So the above `MyPromise` can wait for the `p1` correctly.
JiaLiPassion
force-pushed
the
promise-resolve
branch
from
December 11, 2023 04:18
a2a89a5
to
c7466b5
Compare
alan-agius4
added
action: review
The PR is still awaiting reviews from at least one requested reviewer
and removed
action: global presubmit
The PR is in need of a google3 global presubmit
labels
Dec 11, 2023
devversion
approved these changes
Dec 11, 2023
devversion
added
action: merge
The PR is ready for merge by the caretaker
and removed
action: review
The PR is still awaiting reviews from at least one requested reviewer
labels
Dec 11, 2023
This PR was merged into the repository by commit 08b0c87. |
alxhub
pushed a commit
that referenced
this pull request
Dec 11, 2023
…53423) In the original `Promise` impelmentation, zone.js follow the spec from https://promisesaplus.com/#point-51. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // false ``` in this case, `p2` should be the same status with `p1` but they are still different instances. And for some edge case. ``` class MyPromise extends Promise { constructor(sub) { super((res) => res(null)); this.sub = sub; } then(onFufilled, onRejected) { this.sub.then(onFufilled, onRejected); } } const p1 = new Promise(setTimeout(res), 100); const myP = new MyPromise(p1); const r = await myP; r === 1; // false ``` So in the above code, `myP` is not the same instance with `p1`, and since `myP` is resolved in constructor, so `await myP` will just pass without waiting for `p1`. And in the current `tc39` spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolve `Promise.resolve(subP)` should return `subP`. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // true ``` So the above `MyPromise` can wait for the `p1` correctly. PR Close #53423
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
ChellappanRajan
pushed a commit
to ChellappanRajan/angular
that referenced
this pull request
Jan 23, 2024
…ngular#53423) In the original `Promise` impelmentation, zone.js follow the spec from https://promisesaplus.com/#point-51. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // false ``` in this case, `p2` should be the same status with `p1` but they are still different instances. And for some edge case. ``` class MyPromise extends Promise { constructor(sub) { super((res) => res(null)); this.sub = sub; } then(onFufilled, onRejected) { this.sub.then(onFufilled, onRejected); } } const p1 = new Promise(setTimeout(res), 100); const myP = new MyPromise(p1); const r = await myP; r === 1; // false ``` So in the above code, `myP` is not the same instance with `p1`, and since `myP` is resolved in constructor, so `await myP` will just pass without waiting for `p1`. And in the current `tc39` spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolve `Promise.resolve(subP)` should return `subP`. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // true ``` So the above `MyPromise` can wait for the `p1` correctly. PR Close angular#53423
rlmestre
pushed a commit
to rlmestre/angular
that referenced
this pull request
Jan 26, 2024
…ngular#53423) In the original `Promise` impelmentation, zone.js follow the spec from https://promisesaplus.com/#point-51. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // false ``` in this case, `p2` should be the same status with `p1` but they are still different instances. And for some edge case. ``` class MyPromise extends Promise { constructor(sub) { super((res) => res(null)); this.sub = sub; } then(onFufilled, onRejected) { this.sub.then(onFufilled, onRejected); } } const p1 = new Promise(setTimeout(res), 100); const myP = new MyPromise(p1); const r = await myP; r === 1; // false ``` So in the above code, `myP` is not the same instance with `p1`, and since `myP` is resolved in constructor, so `await myP` will just pass without waiting for `p1`. And in the current `tc39` spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolve `Promise.resolve(subP)` should return `subP`. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // true ``` So the above `MyPromise` can wait for the `p1` correctly. PR Close angular#53423
danieljancar
pushed a commit
to danieljancar/angular
that referenced
this pull request
Jan 26, 2024
…ngular#53423) In the original `Promise` impelmentation, zone.js follow the spec from https://promisesaplus.com/#point-51. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // false ``` in this case, `p2` should be the same status with `p1` but they are still different instances. And for some edge case. ``` class MyPromise extends Promise { constructor(sub) { super((res) => res(null)); this.sub = sub; } then(onFufilled, onRejected) { this.sub.then(onFufilled, onRejected); } } const p1 = new Promise(setTimeout(res), 100); const myP = new MyPromise(p1); const r = await myP; r === 1; // false ``` So in the above code, `myP` is not the same instance with `p1`, and since `myP` is resolved in constructor, so `await myP` will just pass without waiting for `p1`. And in the current `tc39` spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolve `Promise.resolve(subP)` should return `subP`. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // true ``` So the above `MyPromise` can wait for the `p1` correctly. PR Close angular#53423
amilamen
pushed a commit
to amilamen/angular
that referenced
this pull request
Jan 26, 2024
…ngular#53423) In the original `Promise` impelmentation, zone.js follow the spec from https://promisesaplus.com/#point-51. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // false ``` in this case, `p2` should be the same status with `p1` but they are still different instances. And for some edge case. ``` class MyPromise extends Promise { constructor(sub) { super((res) => res(null)); this.sub = sub; } then(onFufilled, onRejected) { this.sub.then(onFufilled, onRejected); } } const p1 = new Promise(setTimeout(res), 100); const myP = new MyPromise(p1); const r = await myP; r === 1; // false ``` So in the above code, `myP` is not the same instance with `p1`, and since `myP` is resolved in constructor, so `await myP` will just pass without waiting for `p1`. And in the current `tc39` spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolve `Promise.resolve(subP)` should return `subP`. ``` const p1 = Promise.resolve(1); const p2 = Promise.resolve(p1); p1 === p2; // true ``` So the above `MyPromise` can wait for the `p1` correctly. PR Close angular#53423
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
action: merge
The PR is ready for merge by the caretaker
area: zones
target: patch
This PR is targeted for the next patch release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Close #53380
In the original
Promise
impelmentation, zone.js follow the spec fromhttps://promisesaplus.com/#point-51.
in this case,
p2
should be the same status withp1
but they arestill different instances.
And for some edge case.
So in the above code,
myP
is not the same instance withp1
,and since
myP
is resolved in constructor, soawait myP
willjust pass without waiting for
p1
.And in the current
tc39
spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolvePromise.resolve(subP)
should returnsubP
.So the above
MyPromise
can wait for thep1
correctly.