broccolijs / broccoli

Browser compilation library – an asset pipeline for applications that run in the browser
https://broccoli.build
MIT License
3.33k stars 217 forks source link

[BUGFIX] no longer cause spurious unhandled promise rejections warnings #450

Closed stefanpenner closed 4 years ago

stefanpenner commented 4 years ago

This PR fixes broccoli to no longer unintentionally trigger node's unhandledRejection warnings.

Specifically these warnings where coming from watcher.currentBuild which is a public API, allowing external consumers to consider the latest builds outcome. For example the broccoli express middleware will on each request follow watcher.currentBuild. On fulfillment it will serve the file in question, or on rejection it will provide a useful error page.

watcher.currentBuild is the downstream promise of several internal watcher promises, each of which already handle rejections correctly appropriately.

This commit ensures external consumers of currentBuild are correctly notified of the final promise state, but without any external consumers rejections of currentBuild are considered handled.


The test here is the addition of failing the test if there are any unhandled rejection warnings.

stefanpenner commented 4 years ago

This appears to be related to https://github.com/ember-cli/ember-cli/issues/9007 I'll hold off on landing this until I fully understand that issue.

stefanpenner commented 4 years ago

confirmed that this does not make ember-cli/ember-cli#9007 worse, rather it is important in landing the relevant fix.