mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
fix(ext/node): don't call undefined nextTick fn (#20724)
The `process` global is not defined in this file. Fixes #20441 --------- Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
6fd2d08418
commit
d5b6c636b0
3 changed files with 31 additions and 1 deletions
|
@ -58,6 +58,7 @@ util::unit_test_factory!(
|
||||||
crypto_hash_test = crypto / crypto_hash_test,
|
crypto_hash_test = crypto / crypto_hash_test,
|
||||||
crypto_key_test = crypto / crypto_key_test,
|
crypto_key_test = crypto / crypto_key_test,
|
||||||
crypto_sign_test = crypto / crypto_sign_test,
|
crypto_sign_test = crypto / crypto_sign_test,
|
||||||
|
events_test,
|
||||||
fs_test,
|
fs_test,
|
||||||
http_test,
|
http_test,
|
||||||
http2_test,
|
http2_test,
|
||||||
|
|
28
cli/tests/unit_node/events_test.ts
Normal file
28
cli/tests/unit_node/events_test.ts
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
import { deferred } from "../../../test_util/std/async/deferred.ts";
|
||||||
|
import { EventEmitter } from "node:events";
|
||||||
|
|
||||||
|
EventEmitter.captureRejections = true;
|
||||||
|
|
||||||
|
Deno.test("regression #20441", async () => {
|
||||||
|
const promise = deferred();
|
||||||
|
|
||||||
|
const ee = new EventEmitter();
|
||||||
|
|
||||||
|
ee.on("foo", function () {
|
||||||
|
const p = new Promise((_resolve, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
reject();
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
return p;
|
||||||
|
});
|
||||||
|
|
||||||
|
ee.on("error", function (_) {
|
||||||
|
promise.resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
ee.emit("foo");
|
||||||
|
await promise;
|
||||||
|
});
|
|
@ -42,6 +42,7 @@ import {
|
||||||
validateFunction,
|
validateFunction,
|
||||||
} from "ext:deno_node/internal/validators.mjs";
|
} from "ext:deno_node/internal/validators.mjs";
|
||||||
import { spliceOne } from "ext:deno_node/_utils.ts";
|
import { spliceOne } from "ext:deno_node/_utils.ts";
|
||||||
|
import { nextTick } from "ext:deno_node/_process/process.ts";
|
||||||
|
|
||||||
const kCapture = Symbol("kCapture");
|
const kCapture = Symbol("kCapture");
|
||||||
const kErrorMonitor = Symbol("events.errorMonitor");
|
const kErrorMonitor = Symbol("events.errorMonitor");
|
||||||
|
@ -206,7 +207,7 @@ function addCatch(that, promise, type, args) {
|
||||||
then.call(promise, undefined, function (err) {
|
then.call(promise, undefined, function (err) {
|
||||||
// The callback is called with nextTick to avoid a follow-up
|
// The callback is called with nextTick to avoid a follow-up
|
||||||
// rejection from this promise.
|
// rejection from this promise.
|
||||||
process.nextTick(emitUnhandledRejectionOrErr, that, err, type, args);
|
nextTick(emitUnhandledRejectionOrErr, that, err, type, args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in a new issue