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

Patch promise constructor fix #25

Merged
merged 3 commits into from
Dec 10, 2024
Merged

Conversation

gzuidhof
Copy link
Contributor

@gzuidhof gzuidhof commented Dec 9, 2024

Fixes #24.

Still putting it through its paces a bit to ensure this doesn't have unwanted side effects.

@gzuidhof gzuidhof added the bug Something isn't working label Dec 9, 2024
@gzuidhof gzuidhof self-assigned this Dec 9, 2024
// of Angular).
if (c === prop) {
return v
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it could be risky to set a precedent of including specific fixes for different 3rd-party tools like Angular? Right now we have just this one, and perhaps it will stay like this, but I could envision a worst-case scenario where this file fills up with lots of different code paths for handling various different frameworks and libraries. We all know how the JavaScript ecosystem moves.

And in this case, it seems like Angular is moving away from these zones anyway. If the recommendation of the maintainers themselves is based on import order, maybe it's not so bad to follow that same pattern?

I don't have a strong feeling about this, though—just some rambly food for thought.

Would it make sense to also constrain this patch to w.Promise[p] by checking the name or target argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be careful with fixes that are done for a particular framework - so I definitely agree with that.

In this case I think the fix doesn't hurt to have for non-Angular users too (it's possible other libaries will also overwrite the constructor). Angular is a pretty big library too (even if moving away from this feature.. some codebases are likely stuck in the past) - so in this case I think it makes sense.

Right now it is constrained to window.Promise.constructor because that's the only constructor we patch, which I think is not going to change for the foreseeable future.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment to remind us if we add new constructor patches

@gzuidhof gzuidhof merged commit f2ea673 into main Dec 10, 2024
2 checks passed
@gzuidhof gzuidhof deleted the patch-promise-constructor-fix branch December 10, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angular 19 ZoneAwarePromise error
2 participants