Version
v24.2.0, v25.0.0-pre
Platform
Linux tumba 6.14.8-gentoo-yuran #2 SMP Tue May 27 17:51:23 +08 2025 x86_64 Intel(R) Core(TM)2 Quad CPU Q8200 @ 2.33GHz GenuineIntel GNU/Linux
Subsystem
fs
What steps will reproduce the bug?
import fs from 'node:fs/promises';
const f = '/tmp/deleteme-utimes-issue-file';
await fs.writeFile(f, '');
console.log('|', 'set', '|', 'got', '|', 'got/set', '|');
console.log('|', '---', '|', '---', '|', '---', '|');
for (let i = 1; i < Number.MAX_SAFE_INTEGER; i *= 3) {
await fs.utimes(f, i, i);
const { mtimeMs } = await fs.stat(f);
console.log('|', i, '|', mtimeMs, '|', mtimeMs / i, '|');
}
await fs.rm(f);
How often does it reproduce? Is there a required condition?
Reproduces on one specific PC all the time. Couldn't reproduce on any other machine so far.
What is the expected behavior? Why is that the expected behavior?
| set |
got |
got/set |
| 1 |
1000 |
1000 |
| 3 |
3000 |
1000 |
| 9 |
9000 |
1000 |
| 27 |
27000 |
1000 |
| 81 |
81000 |
1000 |
| 243 |
243000 |
1000 |
| 729 |
729000 |
1000 |
| 2187 |
2187000 |
1000 |
| 6561 |
6561000 |
1000 |
| 19683 |
19683000 |
1000 |
| 59049 |
59049000 |
1000 |
| 177147 |
177147000 |
1000 |
| 531441 |
531441000 |
1000 |
| 1594323 |
1594323000 |
1000 |
| 4782969 |
4782969000 |
1000 |
| 14348907 |
14348907000 |
1000 |
| 43046721 |
43046721000 |
1000 |
| 129140163 |
129140163000 |
1000 |
| 387420489 |
387420489000 |
1000 |
| 1162261467 |
1162261467000 |
1000 |
| 3486784401 |
3486784401000 |
1000 |
| 10460353203 |
10460353203000 |
1000 |
| 31381059609 |
15032385535000 |
479.0273407685939 |
| 94143178827 |
15032385535000 |
159.67578025619795 |
| 282429536481 |
15032385535000 |
53.22526008539932 |
| 847288609443 |
15032385535000 |
17.741753361799773 |
| 2541865828329 |
15032385535000 |
5.913917787266591 |
| 7625597484987 |
15032385535000 |
1.9713059290888637 |
| 22876792454961 |
15032385535000 |
0.6571019763629545 |
| 68630377364883 |
15032385535000 |
0.21903399212098484 |
| 205891132094649 |
15032385535000 |
0.07301133070699495 |
| 617673396283947 |
15032385535000 |
0.024337110235664983 |
| 1853020188851841 |
15032385535000 |
0.008112370078554995 |
| 5559060566555523 |
15032385535000 |
0.0027041233595183315 |
Expected because 1 second is 1000 milliseconds
What do you see instead?
| set |
got |
got/set |
| 1 |
1002.0566138856454 |
1002.0566138856454 |
| 3 |
3006.169841656936 |
1002.0566138856453 |
| 9 |
9018.509524970808 |
1002.0566138856453 |
| 27 |
27055.528574912427 |
1002.0566138856454 |
| 81 |
81166.58572473728 |
1002.0566138856454 |
| 243 |
243499.75717421185 |
1002.0566138856454 |
| 729 |
730499.2715226355 |
1002.0566138856453 |
| 2187 |
2191497.814567907 |
1002.0566138856456 |
| 6561 |
6574493.443703719 |
1002.0566138856454 |
| 19683 |
19723480.33111116 |
1002.0566138856454 |
| 59049 |
59170440.99333348 |
1002.0566138856454 |
| 177147 |
177511322.98000044 |
1002.0566138856454 |
| 531441 |
532533968.9400013 |
1002.0566138856454 |
| 1594323 |
1597601906.820004 |
1002.0566138856454 |
| 4782969 |
4792805720.4600115 |
1002.0566138856454 |
| 14348907 |
14378417161.380035 |
1002.0566138856454 |
| 43046721 |
43135251484.14011 |
1002.0566138856454 |
| 129140163 |
129405754452.42032 |
1002.0566138856454 |
| 387420489 |
388217263357.2609 |
1002.0566138856453 |
| 1162261467 |
1164651790071.783 |
1002.0566138856456 |
| 3486784401 |
3493955370215.3486 |
1002.0566138856454 |
| 10460353203 |
10481866110646.045 |
1002.0566138856453 |
| 31381059609 |
15063301347825.656 |
480.0125150492224 |
| 94143178827 |
15063301347825.656 |
160.0041716830741 |
| 282429536481 |
15063301347825.656 |
53.33472389435804 |
| 847288609443 |
15063301347825.656 |
17.778241298119347 |
| 2541865828329 |
15063301347825.656 |
5.926080432706449 |
| 7625597484987 |
15063301347825.656 |
1.975360144235483 |
| 22876792454961 |
15063301347825.656 |
0.6584533814118276 |
| 68630377364883 |
15063301347825.656 |
0.2194844604706092 |
| 205891132094649 |
15063301347825.656 |
0.0731614868235364 |
| 617673396283947 |
15063301347825.656 |
0.024387162274512136 |
| 1853020188851841 |
15063301347825.656 |
0.008129054091504046 |
| 5559060566555523 |
15063301347825.656 |
0.002709684697168015 |
Additional information
This issue causes test/parallel/test-fs-cp.mjs, test/parallel/test-fs-promises.js, test/parallel/test-fs-stat-bigint.js, and test/parallel/test-fs-utimes-y2K38.js fail for me locally every time. 😧
This issue persists for statSync(), too.
This issue persists between different filesystems.
This issue does not appear when using bigint option.
This issue does not appear when using touch/stat, or similar functions in other languages.
I suspect some weird bug with floating point.
Version
v24.2.0, v25.0.0-pre
Platform
Subsystem
fs
What steps will reproduce the bug?
import fs from 'node:fs/promises';
const f = '/tmp/deleteme-utimes-issue-file';
await fs.writeFile(f, '');
console.log('|', 'set', '|', 'got', '|', 'got/set', '|');
console.log('|', '---', '|', '---', '|', '---', '|');
for (let i = 1; i < Number.MAX_SAFE_INTEGER; i *= 3) {
await fs.utimes(f, i, i);
const { mtimeMs } = await fs.stat(f);
console.log('|', i, '|', mtimeMs, '|', mtimeMs / i, '|');
}
await fs.rm(f);
How often does it reproduce? Is there a required condition?
Reproduces on one specific PC all the time. Couldn't reproduce on any other machine so far.
What is the expected behavior? Why is that the expected behavior?
Expected because 1 second is 1000 milliseconds
What do you see instead?
Additional information
This issue causes
test/parallel/test-fs-cp.mjs,test/parallel/test-fs-promises.js,test/parallel/test-fs-stat-bigint.js, andtest/parallel/test-fs-utimes-y2K38.jsfail for me locally every time. 😧This issue persists for
statSync(), too.This issue persists between different filesystems.
This issue does not appear when using
bigintoption.This issue does not appear when using
touch/stat, or similar functions in other languages.I suspect some weird bug with floating point.