Skip to content

Commit 247dfb7

Browse files
vramanatargos
authored andcommitted
dgram: fix unhandled exception aborting a closed udp socket
Fixes: #46750 PR-URL: #46770 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 92f2f19 commit 247dfb7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/dgram.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function Socket(type, listener) {
139139
const { signal } = options;
140140
validateAbortSignal(signal, 'options.signal');
141141
const onAborted = () => {
142-
this.close();
142+
if (this[kStateSymbol].handle) this.close();
143143
};
144144
if (signal.aborted) {
145145
onAborted();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
require('../common');
3+
const dgram = require('dgram');
4+
5+
const controller = new AbortController();
6+
const socket = dgram.createSocket({ type: 'udp4', signal: controller.signal });
7+
8+
socket.close();
9+
10+
controller.abort();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy