Skip to content

fs.utimes doesn't support number or string on Windows #33227

Closed
@SimenB

Description

@SimenB
  • Version: v13.14.0 (unable to install v14 on windows 7)
  • Platform: Microsoft Windows Server 2019 (GH Actions Windows CI) & 32 bit Windows 7
  • Subsystem: fs

What steps will reproduce the bug?

const fs = require('fs');

fs.utimesSync(__filename, Date.now(), Date.now());
const fs = require('fs');

fs.utimesSync(__filename, Date.now().toString(), Date.now().toString());

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

Always

What is the expected behavior?

It should work same as Linux and Mac

What do you see instead?

  ● does not re-run tests when only access time is modified

    EINVAL: invalid argument, utime 'C:\Users\RUNNER~1\AppData\Local\Temp\watch_mode_no_access\foo.js'

      61 |   const modulePath = path.join(DIR, 'foo.js');
      62 |   const stat = fs.lstatSync(modulePath);
    > 63 |   fs.utimesSync(modulePath, stat.atime.getTime(), stat.mtime.getTime());
         |      ^
      64 | 
      65 |   await testRun.waitUntil(({stderr}) => numberOfTestRuns(stderr) === 2);
      66 | 

      at Object.utimesSync (e2e/__tests__/watchModeNoAccess.test.ts:63:6)

That's from this CI run, where the same test passes on both Linux and Mac: https://github.com/facebook/jest/runs/641141754

Additional information

According to the docs, utimes can take number | string | Date: https://nodejs.org/api/fs.html#fs_fs_utimes_path_atime_mtime_callback. Seems like Windows only supports Date?

This is the same as #5561.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions