Inconsistent behavior across platforms when importing `node:http` after defining `Object.prototype['0']`
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.10.0
Platform
Microsoft Windows NT 10.0.26200.0 x64
and
Linux KContainer 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 x86_64 x86_64 GNU/Linux
Subsystem
No response
What steps will reproduce the bug?
Hi,
The behavior can be reproduced by running the following snippet:
Object.defineProperty(Object.prototype, '0', {
set() {
console.log(123);
}
});
import http from "node:http"
Run this code by creating a file a.js in Both Linux and Windows and observe a difference in output.
How often does it reproduce? Is there a required condition?
File extension must be .js
Use import http from "node:http" instead of const http = require('http');
What is the expected behavior? Why is that the expected behavior?
Code should give same output when run in both Linux and Windows
What do you see instead?
Linux:
root@KContainer:~/git/run/test# node test.js
123
(node:1547) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/c01kele/git/run/test/test.js is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /home/c01kele/package.json.
(Use `node --trace-warnings ...` to show where the warning was created)
123
123
123
Windows:
PS D:\HIWI\RESULTS\31_10_2025> node .\test.js
PS D:\HIWI\RESULTS\31_10_2025>
If you use const http = require('http'); instead of import http from "node:http", both Linux and Windows give no output.
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
Beginne damit, die a.js-Reproduktion des Issues mit dem node:http-Import in den gemeldeten Linux- und Windows-Umgebungen auszuführen, und vergleiche sie anschließend mit dem require('http')-Fall. Verfolge den Importpfad des integrierten Moduls, der am Plattformunterschied beteiligt ist; als abgeschlossen gilt die Aufgabe, wenn auf beiden Plattformen dieselbe Ausgabe erzeugt wird, ohne die Reproduktion zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- backend, operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100