[BUG] The temporary file name is longer than the target file name

Open
#63 0 comments 0 reactions 0 assignees View on GitHub

@jovial-liu is already working on this.

Since Oct 8, 2026.

  • #240 by @cpruijsen — closed without merging
  • #242 by @jovial-liu — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript
Domain
tooling

Research direction

Start by locating where the library constructs the temporary filename, then reproduce the issue with a target filename one character below the filesystem limit. Done means the temporary filename is no longer longer than the target and the long-name case avoids ENAMETOOLONG.

Written by the indexing model from the issue text.

Description

Bug

What / Why

This library creates a temp file by appending some hash to the target file name. This is bad because when the target file name is really long (but still inside the filesystem limit) the temp file name might get out of that limit and a ENAMETOOLONG error will happen

We started to have this issue in pnpm v5, where we have really long file names in the content-addressable storage.
Related issue: https://github.com/pnpm/pnpm/issues/2605

How

Current Behavior

The temp file name is the <target file>.<hash>

Steps to Reproduce

Write a file that has a name 1 character shorter than the accepted limit.

Expected Behavior

The temp file name is short or at least not longer than the target file name.

References

https://github.com/pnpm/pnpm/issues/2605

Dominant language
JavaScript
Stars
256
Forks
51
PR merge metrics
No merged PRs in 30d

Getting set up

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.

More from npm/write-file-atomic

All issues in npm/write-file-atomic

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.