`net.Socket({ fd })` can abort the Node.js process when iterating invalid file descriptors
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
Version
24.13.1
Platform
Linux KContainer 6.12.86+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.86-1 (2026-05-08) x86_64 x86_64 x86_64 GNU/Linux
Subsystem
net
What steps will reproduce the bug?
Hi,
I found a case where creating net.Socket instances with arbitrary file descriptors can abort the entire Node.js process.
const net = require('net');
let fd = 3;
while (fd < 1000) {
try {
const stream = new net.Socket({
fd: fd,
readable: false,
writable: true
});
stream.on('error', function () {});
stream.write('might crash');
} catch (e) {
// ignore and continue to next fd
console.log('caught')
}
fd += 1;
}
How often does it reproduce? Is there a required condition?
Reproduces consistently on my system.
What is the expected behavior? Why is that the expected behavior?
Invalid or unsupported file descriptors passed to net.Socket({ fd }) should result in ordinary JS exceptions or socket errors, not process abort.
What do you see instead?
Some file descriptors are handled normally and throw JS exceptions that are caught successfully, but eventually Node aborts the process:
root@KContainer:~/git/run/cerebras/node/OPENAI/gpt5.1/filter/batch_3/cross_runtime/temp_deno/3604# node repro.cjs caught caught caught caught
caught
caught
....
caught
caught
caught
caught
caught
caught
caught
caught
Aborted
The abort bypasses JS exception handling entirely.
Additional information
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der bereitgestellten JavaScript-Reproduktion und dem Pfad net.Socket({ fd }) unter Linux. Konzentrieren Sie sich darauf, wie ungültige Deskriptoren vor stream.write() behandelt werden. Bestätigen Sie, dass der Abbruch reproduzierbar ist, und überprüfen Sie anschließend, dass ungültige oder nicht unterstützte Deskriptoren abfangbare JavaScript-Ausnahmen oder Socket-Fehler erzeugen, ohne den Prozess zu beenden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- networking
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100