diff options
Diffstat (limited to 'ext/node/polyfills/internal_binding/handle_wrap.ts')
-rw-r--r-- | ext/node/polyfills/internal_binding/handle_wrap.ts | 7 |
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() { |