Skip to content

Commit

Permalink
dgram: fix unhandled exception aborting a closed udp socket
Browse files Browse the repository at this point in the history
Fixes: #46750
PR-URL: #46770
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
vramana authored and targos committed Mar 13, 2023
1 parent 92f2f19 commit 247dfb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function Socket(type, listener) {
const { signal } = options;
validateAbortSignal(signal, 'options.signal');
const onAborted = () => {
this.close();
if (this[kStateSymbol].handle) this.close();
};
if (signal.aborted) {
onAborted();
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-dgram-abort-closed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';
require('../common');
const dgram = require('dgram');

const controller = new AbortController();
const socket = dgram.createSocket({ type: 'udp4', signal: controller.signal });

socket.close();

controller.abort();

0 comments on commit 247dfb7

Please sign in to comment.