fix(zone.js): read Symbol.species safely#45369
Closed
arturovt wants to merge 1 commit intoangular:masterfrom
Closed
fix(zone.js): read Symbol.species safely#45369arturovt wants to merge 1 commit intoangular:masterfrom
Symbol.species safely#45369arturovt wants to merge 1 commit intoangular:masterfrom
Conversation
d34c87c to
3832751
Compare
Contributor
|
@arturovt , thank you for the PR, could you add a test case around here ? |
JiaLiPassion
suggested changes
Mar 17, 2022
Contributor
JiaLiPassion
left a comment
There was a problem hiding this comment.
Need to add test case
09a6baa to
2ae2267
Compare
We must read `Symbol.species` safely because `this` may be anything. For instance, `this` may be an object without a prototype (created through `Object.create(null)`); thus `this.constructor` will be undefined. One of the use cases is SystemJS creating prototype-less objects (modules) via `Object.create(null)`. The SystemJS creates an empty object and copies promise properties into that object (within the `getOrCreateLoad` function). The zone.js then checks if the resolved value has the `then` method and invokes it with the `value` context. Otherwise, this will throw an error: `TypeError: Cannot read properties of undefined (reading 'Symbol(Symbol.species)')`.
2ae2267 to
0046c5d
Compare
Contributor
|
@arturovt @JiaLiPassion Is this ready to be merged? |
Contributor
|
@dylhunn , yes, this one is ready to merge, thank you. |
Contributor
|
This PR was merged into the repository by commit e2eaac3. |
dylhunn
pushed a commit
that referenced
this pull request
Mar 25, 2022
We must read `Symbol.species` safely because `this` may be anything. For instance, `this` may be an object without a prototype (created through `Object.create(null)`); thus `this.constructor` will be undefined. One of the use cases is SystemJS creating prototype-less objects (modules) via `Object.create(null)`. The SystemJS creates an empty object and copies promise properties into that object (within the `getOrCreateLoad` function). The zone.js then checks if the resolved value has the `then` method and invokes it with the `value` context. Otherwise, this will throw an error: `TypeError: Cannot read properties of undefined (reading 'Symbol(Symbol.species)')`. PR Close #45369
|
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. |
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.
We must read
Symbol.speciessafely becausethismay be anything. For instance,thismay be an object without a prototype (created through
Object.create(null)); thusthis.constructorwill be undefined. One of the use cases is SystemJS creatingprototype-less objects (modules) via
Object.create(null). The SystemJS creates an emptyobject and copies promise properties into that object (within the
getOrCreateLoadfunction). The zone.js then checks if the resolved value has the
thenmethod and invokesit with the
valuecontext. Otherwise, this will throw an error:TypeError: Cannot read properties of undefined (reading 'Symbol(Symbol.species)').PR Checklist
PR Type
Does this PR introduce a breaking change?