fix(zone.js): Promise.resolve(subPromise) should return subPromise#53423
Closed
JiaLiPassion wants to merge 1 commit intoangular:mainfrom
Closed
fix(zone.js): Promise.resolve(subPromise) should return subPromise#53423JiaLiPassion wants to merge 1 commit intoangular:mainfrom
JiaLiPassion wants to merge 1 commit intoangular:mainfrom
Conversation
alan-agius4
approved these changes
Dec 7, 2023
devversion
reviewed
Dec 7, 2023
660838b to
d31bdc1
Compare
Contributor
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.
a2a89a5 to
c7466b5
Compare
devversion
approved these changes
Dec 11, 2023
Member
|
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
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
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
Promiseimpelmentation, zone.js follow the spec fromhttps://promisesaplus.com/#point-51.
in this case,
p2should be the same status withp1but they arestill different instances.
And for some edge case.
So in the above code,
myPis not the same instance withp1,and since
myPis resolved in constructor, soawait myPwilljust pass without waiting for
p1.And in the current
tc39spec here https://tc39.es/ecma262/multipage/control-abstraction-objects.html#sec-promise-resolvePromise.resolve(subP)should returnsubP.So the above
MyPromisecan wait for thep1correctly.