diff options
Diffstat (limited to 'ext/node/polyfills/internal_binding/udp_wrap.ts')
-rw-r--r-- | ext/node/polyfills/internal_binding/udp_wrap.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/node/polyfills/internal_binding/udp_wrap.ts b/ext/node/polyfills/internal_binding/udp_wrap.ts index 619950997..209c84a23 100644 --- a/ext/node/polyfills/internal_binding/udp_wrap.ts +++ b/ext/node/polyfills/internal_binding/udp_wrap.ts @@ -78,6 +78,7 @@ export class UDP extends HandleWrap { #listener?: Deno.DatagramConn; #receiving = false; + #unrefed = false; #recvBufferSize = UDP_DGRAM_MAXSIZE; #sendBufferSize = UDP_DGRAM_MAXSIZE; @@ -273,7 +274,8 @@ export class UDP extends HandleWrap { } override ref() { - notImplemented("udp.UDP.prototype.ref"); + this.#listener?.ref(); + this.#unrefed = false; } send( @@ -315,7 +317,8 @@ export class UDP extends HandleWrap { } override unref() { - notImplemented("udp.UDP.prototype.unref"); + this.#listener?.unref(); + this.#unrefed = true; } #doBind(ip: string, port: number, _flags: number, family: number): number { @@ -443,6 +446,10 @@ export class UDP extends HandleWrap { let remoteAddr: Deno.NetAddr | null; let nread: number | null; + if (this.#unrefed) { + this.#listener!.unref(); + } + try { [buf, remoteAddr] = (await this.#listener!.receive(p)) as [ Uint8Array, |