Skip to content

fs.writeFileSync regression in v21.3.0 on MacOS #50989

Closed
@jeremymeng

Description

@jeremymeng

Version

v21.3.0

Platform

Darwin [email protected] 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64

Subsystem

fs

What steps will reproduce the bug?

Run the following code with Node v21.3.0

const { mkdtempSync, writeFileSync } = require("fs")
const { join } = require("path")
const { tmpdir } = require("os")

const testTitle = "azure-arc";
const tempDir = mkdtempSync(join(tmpdir(), testTitle));
const tempFile = join(tempDir, testTitle);
const key = "challenge key";
console.dir({ tempFile })
writeFileSync(tempFile, key, { encoding: "utf8" });

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

always

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

V21.2.0 worked as expected

ym@air node-test % nvm use 21.2.0
Now using node v21.2.0 (npm v10.2.3)
ym@air node-test % node fs.js    
{
  tempFile: '/var/folders/hn/r4xrm7195j5gqyr4dj4tmd3r0000gp/T/azure-arclhqY5s/azure-arc'
}
ym@air node-test % cat /var/folders/hn/r4xrm7195j5gqyr4dj4tmd3r0000gp/T/azure-arclhqY5s/azure-arc
challenge key

What do you see instead?

{
  tempFile: '/var/folders/hn/r4xrm7195j5gqyr4dj4tmd3r0000gp/T/azure-arcpSm7cb/azure-arc'
}
node:fs:2352
    return binding.writeFileUtf8(
                   ^

Error: ENOENT: no such file or directory, open '/var/folders/hn/r4xrm7195j5gqyr4dj4tmd3r0000gp/T/azure-arcpSm7cb/azure-arc'
    at writeFileSync (node:fs:2352:20)
    at Object.<anonymous> (/Users/ym/working/node-test/fs.js:12:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
    at node:internal/main/run_main_module:28:49 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/var/folders/hn/r4xrm7195j5gqyr4dj4tmd3r0000gp/T/azure-arcpSm7cb/azure-arc'
}

Node.js v21.3.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    fsIssues and PRs related to the fs subsystem / file system.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions