summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal_binding
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2024-07-24 20:33:45 +0900
committerGitHub <noreply@github.com>2024-07-24 20:33:45 +0900
commit199a8ca4c5a8c5b2a060ef6a8912766a6a98d0b7 (patch)
treef285ddbf9fa59687d5d0bc3610152af41f887a30 /ext/node/polyfills/internal_binding
parent29934d558c188fdc3406706da19921ca5a389383 (diff)
fix(ext/node/net): emit `error` before `close` when connection is refused (#24656)
Diffstat (limited to 'ext/node/polyfills/internal_binding')
-rw-r--r--ext/node/polyfills/internal_binding/handle_wrap.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/node/polyfills/internal_binding/handle_wrap.ts b/ext/node/polyfills/internal_binding/handle_wrap.ts
index fd17a1edb..ef8457338 100644
--- a/ext/node/polyfills/internal_binding/handle_wrap.ts
+++ b/ext/node/polyfills/internal_binding/handle_wrap.ts
@@ -25,13 +25,12 @@
// - https://github.com/nodejs/node/blob/master/src/handle_wrap.h
// TODO(petamoriken): enable prefer-primordials for node polyfills
-// deno-lint-ignore-file prefer-primordials
-
import { unreachable } from "ext:deno_node/_util/asserts.ts";
import {
AsyncWrap,
providerType,
} from "ext:deno_node/internal_binding/async_wrap.ts";
+import { nextTick } from "ext:deno_node/_process/process.ts";
export class HandleWrap extends AsyncWrap {
constructor(provider: providerType) {
@@ -40,7 +39,9 @@ export class HandleWrap extends AsyncWrap {
close(cb: () => void = () => {}) {
this._onClose();
- queueMicrotask(cb);
+ // We need to delay 'cb' at least 2 ticks to avoid "close" event happenning before "error" event in net.Socket
+ // See https://github.com/denoland/deno/pull/24656 for more information
+ nextTick(nextTick, cb);
}
ref() {