Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Passing large value for mode option in `fs.createWriteStream` results in crash | GoodFirstPicks

Passing large value for mode option in `fs.createWriteStream` results in crash

nodejs/node 1 comments 11h ago
View on GitHub
lowopenScope: clearSkill match: yesTest focusedNode.jsJavaScript

Why this is a good first issue

The issue involves a clear regression in mode validation for fs.createWriteStream.

AI Summary

The issue reports a regression where passing a large value for the mode option in fs.createWriteStream causes a crash instead of throwing a RangeError. The fix likely involves adjusting the C++ validation to match the previous JS behavior. The regression was introduced by a specific PR and has clear reproduction steps.

Issue Description

Version

v24.13.1, v25.8.1

Platform

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

node fs

What steps will reproduce the bug?

Hi,

The bug can be reproduced using the below snippet:

const { createWriteStream } = require('fs');

createWriteStream('./1.txt', {
  mode: 2176057344,
});

How often does it reproduce? Is there a required condition?

Now special condition. Reproduces all the time

What is the expected behavior? Why is that the expected behavior?

Throw a RangeError which is catchable

root@KContainer:~/37430# deno run -A repro.cjs
error: Uncaught RangeError: The value of "mode" is out of range. It must be >= 0 && <= 4294967295. Received 2176057344
    at parseFileMode (ext:deno_node/internal/validators.mjs:68:3)
    at Module.open (node:fs:1096:12)
    at WriteStream._construct (ext:deno_node/internal/fs/streams.mjs:78:17)
    at constructNT (ext:deno_node/internal/streams/destroy.js:307:12)
    at processTicksAndRejections (ext:core/01_core.js:370:17)
    at drainTicks (ext:core/01_core.js:427:5)

What do you see instead?

Assertion failure

root@KContainer:~/37430# node repro.cjs

  #  node[2434]: void node::fs::Open(const v8::FunctionCallbackInfo<v8::Value>&) at ../src/node_file.cc:2157
  #  Assertion failed: args[2]->IsInt32()

----- Native stack trace -----

 1: 0x8aa857 node::Assert(node::AssertionInfo const&) [node]
 2: 0x8c4c3a  [node]
 3: 0x7f540fdcf08d

----- JavaScript stack trace -----

1: open (node:fs:548:11)
2: _construct (node:internal/fs/streams:73:17)
3: constructNT (node:internal/streams/destroy:300:12)
4: processTicksAndRejections (node:internal/process/task_queues:88:21)


Aborted

Additional information

This was previously reported and fixed. I believe this is a regression https://github.com/nodejs/node/issues/37430

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • regression
  • C++ assertion
Loading labels...

Details

Points10 pts
Difficultylow
Scopeclear
Skill Matchyes
Test Focusedyes