fix(fslib): handle float timestamps in convertToBigIntStats#6988
Merged
arcanis merged 6 commits intoyarnpkg:masterfrom Nov 26, 2025
Merged
fix(fslib): handle float timestamps in convertToBigIntStats#6988arcanis merged 6 commits intoyarnpkg:masterfrom
arcanis merged 6 commits intoyarnpkg:masterfrom
Conversation
Fixes RangeError when file timestamps contain fractional milliseconds. Uses Math.floor() to ensure integer conversion before BigInt. The convertToBigIntStats function was failing when stats contained non-integer timestamps (e.g., 1763746784088.47), throwing: 'RangeError: The number X cannot be converted to a BigInt because it is not an integer' This can occur when ZIP file entries have timestamps with floating-point precision, particularly in Yarn 6.0.0-rc.5 when building with Storybook.
arcanis
reviewed
Nov 24, 2025
Comment on lines
202
to
205
| bigintStats.atimeNs = bigintStats.atimeMs * BigInt(1e6); | ||
| bigintStats.mtimeNs = bigintStats.mtimeMs * BigInt(1e6); | ||
| bigintStats.ctimeNs = bigintStats.ctimeMs * BigInt(1e6); | ||
| bigintStats.birthtimeNs = bigintStats.birthtimeMs * BigInt(1e6); |
Member
There was a problem hiding this comment.
These also need to be updated, as otherwise we lose the millisecond precision. Something like this should work, I think:
bigintStats.atimeNs = bigintStats.atimeMs * BigInt(1e6) + BigInt(Math.floor((stats.atimeMs % 1) * 1e3)) * BigInt(1e3);
bigintStats.mtimeNs = bigintStats.mtimeMs * BigInt(1e6) + BigInt(Math.floor((stats.mtimeMs % 1) * 1e3)) * BigInt(1e3);
bigintStats.ctimeNs = bigintStats.ctimeMs * BigInt(1e6) + BigInt(Math.floor((stats.ctimeMs % 1) * 1e3)) * BigInt(1e3);
bigintStats.birthtimeNs = bigintStats.birthtimeMs * BigInt(1e6) + BigInt(Math.floor((stats.birthtimeMs % 1) * 1e3)) * BigInt(1e3);
Contributor
Author
There was a problem hiding this comment.
Updated - great suggestion 👍
Address review feedback from @arcanis to preserve the fractional part of floating-point timestamps when converting to nanoseconds. The fractional milliseconds (e.g., 0.47ms from 1763746784088.47) are now extracted and added as additional nanoseconds: - 0.47ms → 470μs → 470,000ns This ensures no precision is lost during the conversion process.
Gudahtt
added a commit
to Gudahtt/berry
that referenced
this pull request
Feb 9, 2026
…lowlist * origin/master: (212 commits) CI: Select node version to run CI against automatically (yarnpkg#7032) Fixes foreach order when --topological isnt set (yarnpkg#6997) fix(fslib): handle float timestamps in convertToBigIntStats (yarnpkg#6988) Fixes the `/<name>/<version>` format (yarnpkg#6993) docs(constraints): add missing @typedef alias for `Context` (yarnpkg#6989) Sync master with the changes from master Releasing 3 new packages Fix JSON Schema (yarnpkg#6973) Implements npm web login support (yarnpkg#6981) fix(git): split `-c` and `core.autocrlf=false` into separate args for `clone` (yarnpkg#6983) Sync master with the changes from master Releasing 8 new packages Allow catalogs to work with descriptors without resolvers (yarnpkg#6930) docs: Clarify additional use-case of npmMinimalAgeGate (yarnpkg#6945) Migrates the "typescript" dependencies to a catalog (yarnpkg#6969) Support escaping template variables in environment values (yarnpkg#6935) Core: Create DURATION settings type (yarnpkg#6942) fix: use correct env var to detect gitlab CI for OIDC (yarnpkg#6938) Update README.md badge link (yarnpkg#6947) fix(publish): use correct workspace name in --json output (yarnpkg#6949) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes RangeError when converting floating-point timestamps to BigInt in the
convertToBigIntStatsfunction.Problem
The
convertToBigIntStats()function fails when file stats contain non-integer timestamps (e.g.,1763746784088.47), throwing:This occurs when ZIP file entries have timestamps with floating-point precision, particularly observed in Yarn 6.0.0-rc.5 when building with Storybook.
Solution
Use
Math.floor()to ensure integer values before BigInt conversion on line 194 ofpackages/yarnpkg-fslib/sources/statUtils.ts.Changes
BigInt(element)toBigInt(Math.floor(element))Testing
Related
This issue was discovered while running
yarn storybook buildwith Yarn 6.0.0-rc.5.