mirror of
https://github.com/denoland/deno.git
synced 2024-12-27 17:49:08 -05:00
0bb5bbc7a0
This commit fixes emitting "unhandledrejection" event when there are "node:" or "npm:" imports. Before this commit the Node "unhandledRejection" event was emitted using a regular listener for Web "unhandledrejection" event. This listener was installed before any user listener had a chance to be installed which effectively prevent emitting "unhandledrejection" events to user code. Closes https://github.com/denoland/deno/issues/16928
17 lines
346 B
TypeScript
17 lines
346 B
TypeScript
import chalk from "npm:chalk";
|
|
|
|
console.log(chalk.red("Hello world!"));
|
|
|
|
globalThis.addEventListener("unhandledrejection", (e) => {
|
|
console.log("Handled the promise rejection");
|
|
e.preventDefault();
|
|
});
|
|
|
|
// deno-lint-ignore require-await
|
|
(async () => {
|
|
throw new Error("boom!");
|
|
})();
|
|
|
|
setTimeout(() => {
|
|
console.log("Success");
|
|
}, 1000);
|