Skip to content

Conversation

@pschiel
Copy link
Contributor

@pschiel pschiel commented Jan 19, 2026

Store actual file mtime instead of Date.now()

Currently. Date.now() is stored as file mtime, instead of the actual file mtime.

Issue becomes immediately apparent on Windows due to how Windows updates file timestamps, resulting in ~1ms difference, causing flaky fails in apply_patch.test.ts

Fix

  • Change FileTime.read() to store actual file mtime instead of Date.now()
  • This fixes timing jitter issues where mtime could be ahead of Date.now()
  • Make FileTime.read() async and add await to all callers
  • Fix apply_patch logic to not read mtime of deleted/moved files
  • Add 25ms delay before test cleanup to allow file handles to release

- Change FileTime.read() to store actual file mtime instead of Date.now()
- This fixes timing jitter issues where mtime could be ahead of Date.now()
- Make FileTime.read() async and add await to all callers
- Fix apply_patch logic to not read mtime of deleted/moved files
- Add 25ms delay before test cleanup to allow file handles to release
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #6744: fix(file): resolve 1ms timestamp race in sequential file edits (#8624)
#6744

This PR appears to be addressing the same issue - it's specifically about resolving a 1ms timestamp race condition in file edits, which is exactly what the current PR (9450) is fixing by using actual file mtime instead of Date.now() to avoid timing jitter issues.

@pschiel pschiel marked this pull request as ready for review January 19, 2026 18:17
Copy link

@mdsiaofficial mdsiaofficial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this actually applying?

@pschiel
Copy link
Contributor Author

pschiel commented Jan 20, 2026

is this actually applying?

has anyone ever run the test suite on a win32 system? (these show where it applies)

Copy link

@mdsiaofficial mdsiaofficial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no win32. in win64

@pschiel
Copy link
Contributor Author

pschiel commented Jan 20, 2026

Sorry I don't know what you mean. There is no win64 in nodejs process.platform.

All modern windows systems report win32. It's in your code already.

Did you assume I was testing with Windows 95?

@pschiel pschiel closed this Jan 20, 2026
@mdsiaofficial
Copy link

no. i actually meant windows 64 bit. maybe im wrong.

@pschiel
Copy link
Contributor Author

pschiel commented Jan 20, 2026

no. i actually meant windows 64 bit. maybe im wrong.

It's ridiculous you assume anyone talks about a 32bit system.

There is an exact 0% chance that anyone ran your test suite even once successfully on any Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants