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 <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>
  • 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.