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

Event is not triggered when Promise resolver throws #7

Open
l1bbcsg opened this issue Dec 20, 2017 · 0 comments
Open

Event is not triggered when Promise resolver throws #7

l1bbcsg opened this issue Dec 20, 2017 · 0 comments

Comments

@l1bbcsg
Copy link

l1bbcsg commented Dec 20, 2017

Steps to reproduce

Run polyfill in environment that natively supports unhandledrejection event (tested in Chrome 65).

Sample code

window.addEventListener('unhandledrejection', (e) => {
	if (e instanceof PromiseRejectionEvent) {
		console.log('native unhandledrejection', e.reason)
	} else {
		console.log('polyfilled unhandledrejection', e.reason)
	}
});
polyfill(); // force polyfill
// A
new Promise((resolve, reject) => reject('simple reject'));

// B
Promise.reject('static reject');

// C
new Promise((resolve, reject) => {
	throw new Error('throw');
});

Expected results

Both native and polyfill events fire consistently.

Actual results

Native unhandledrejection fires in all three cases.
Polyfilled unhandledrejection fires in cases A and B, but not C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant