nodejs / nodejs/node

node:fs: calling writeFileSync/appendFileSync with negative 0 causes an assertion failure

Open
#65,886 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

fs
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

Version

v26.8.1

Platform
Linux nixdesk 6.18.48 #1-NixOS SMP PREEMPT_DYNAMIC Fri Aug 28 06:22:54 UTC 2026 x86_64 GNU/Linux
Subsystem

fs

What steps will reproduce the bug?

require("node:fs").writeFileSync(-0, "")

or

require("node:fs").appendFileSync(-0, "")

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

it always happens on my machine. i have not tried on any other computer or os

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

for it to do the same thing as positive zero i assume

What do you see instead?
❯ echo 'require("node:fs").writeFileSync(-0, "")' | node -

  #  node[264400]: void node::fs::WriteFileUtf8(const v8::FunctionCallbackInfo<v8::Value>&) at ../../src/node_file.cc:2764
  #  Assertion failed: (*path) != nullptr

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

 1: 0x629c801c0228  [node]
 2: 0x629c801c0b97 node::Assert(node::AssertionInfo const&) [node]
 3: 0x629c801cda7b  [node]
 4: 0x729babdcfae9 

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

1: writeFileSync (node:fs:2997:20)
2: [stdin]:1:20
3: runScriptInThisContext (node:internal/vm:219:10)
4: node:internal/process/execution:485:12
5: [stdin]-wrapper:6:24
6: runScriptInContext (node:internal/process/execution:483:60)
7: evalFunction (node:internal/process/execution:317:30)
8: evalTypeScript (node:internal/process/execution:329:3)
9: node:internal/main/eval_stdin:51:5
10: node:internal/process/execution:239:5


fish: Job 1, 'echo 'require("node:fs").writeF…' terminated by signal SIGABRT (Abort)
Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/node_file.cc around the WriteFileUtf8 assertion reported at line 2764, using the writeFileSync(-0, "") and appendFileSync(-0, "") reproductions. Trace how the fs APIs handle the path argument and add coverage for negative zero; done means neither call aborts and both behave like positive zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.