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

PromiseRejectionEvent not fired #55590

Open
Joozty opened this issue Apr 30, 2024 · 0 comments
Open

PromiseRejectionEvent not fired #55590

Joozty opened this issue Apr 30, 2024 · 0 comments

Comments

@Joozty
Copy link

Joozty commented Apr 30, 2024

Which @angular/* package(s) are the source of the bug?

zone.js

Is this a regression?

No

Description

The PromiseRejectionEvent is not triggered when zone.js is included on the webpage. The issue stems from zone.js's inability to construct a PromiseRejectionEvent because options parameter is undefined - { promise: undefined, reason: undefined }

Event is not fired and silently ignored here: https://github.com/angular/angular/blob/main/packages/zone.js/lib/common/promise.ts#L82
Fails to construct PromiseRejection error here: https://github.com/angular/angular/blob/main/packages/zone.js/lib/browser/browser.ts#L316

image

Here is a minimal example to reproduce the issue. Note that if you remove the zone.js script, the event fires as expected.

<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<title>Title</title>
		<script src="https://cdn.jsdelivr.net/npm/zone.js@0.14.4/bundles/zone.umd.min.js"></script>
	</head>
	<body>
		<script>
			window.addEventListener('unhandledrejection', (event) =>
				console.log('unhandledrejection', event, event.promise, event.reason),
			)

			const scriptEl = document.createElement('script')
			scriptEl.innerHTML = "Promise.reject('Error happened :(')"
			document.body.append(scriptEl)
		</script>
	</body>
</html>

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

zone.js: latest

Anything else?

No response

@ngbot ngbot bot added this to the needsTriage milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants