2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-10-02 08:13:57 -04:00
|
|
|
|
|
|
|
import { EventEmitter } from "node:events";
|
|
|
|
|
|
|
|
EventEmitter.captureRejections = true;
|
|
|
|
|
|
|
|
Deno.test("regression #20441", async () => {
|
2023-11-22 06:11:20 -05:00
|
|
|
const { promise, resolve } = Promise.withResolvers<void>();
|
2023-10-02 08:13:57 -04:00
|
|
|
|
|
|
|
const ee = new EventEmitter();
|
|
|
|
|
|
|
|
ee.on("foo", function () {
|
|
|
|
const p = new Promise((_resolve, reject) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
reject();
|
|
|
|
}, 100);
|
|
|
|
});
|
|
|
|
return p;
|
|
|
|
});
|
|
|
|
|
|
|
|
ee.on("error", function (_) {
|
2023-11-22 06:11:20 -05:00
|
|
|
resolve();
|
2023-10-02 08:13:57 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
ee.emit("foo");
|
|
|
|
await promise;
|
|
|
|
});
|