Skip to content

unhandledrejection event fires after Zone handles Bluebird rejection #31701

@joews

Description

@joews

Zone.js patched version from #1114 / #1119 (https://github.com/JiaLiPassion/zone.js/tree/bluebird-then-release)
Bluebird 3.5.0
Chrome 67

I'm not sure if this is a usage problem or a bug, but I suspect the latter.

The unhandledrejection event is triggered for Bluebird Promise rejections, even if a Zone's onHandleError callback has handled the error. This doesn't happen with ZoneAwarePromise.

Repro: https://jsfiddle.net/8cyj7rnL/16/

Comment out the Bluebird patch on line 10 to see the difference.

<html>
<head>

<script src="https://unpkg.com/bluebird"></script>
<script src="https://rawgit.com/JiaLiPassion/zone.js/bluebird-then-release/dist/zone.js"></script>
<script src="https://rawgit.com/JiaLiPassion/zone.js/bluebird-then-release/dist/zone-bluebird.js"></script>
<script>
var Bluebird = window.P;

Zone[Zone["__symbol__"]("bluebird")](Bluebird);

window.addEventListener("unhandledrejection", (e) => {
	console.log("unhandled rejection (only called with Bluebird patch)", e.detail.reason.message);
});

Zone.current.fork({
  name: "test zone",
  onHandleError(a, b, c, err) {
		console.log("Zone handled err", err.message);
  }
}).run(() => {
  return Promise.reject(new Error("error in promise rejection"));
})

</script>
</head>
</html>

Metadata

Metadata

Assignees

Labels

area: zonesIssues related to zone.js

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions