Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time set incorrectly in Node 12 #276

Closed
knightjdr opened this issue Oct 8, 2019 · 4 comments · Fixed by #277
Closed

Time set incorrectly in Node 12 #276

knightjdr opened this issue Oct 8, 2019 · 4 comments · Fixed by #277

Comments

@knightjdr
Copy link

If I use Node 10, I don't encounter any issues. But using Node 12 (specifically 12.10.0), the file times aren't being set correctly.

If I create a file like this:

mockFS.file({
  content: '',
})

fs.stat returns 31 Aug, 51738 for the atime and mtime, and invalid for ctime.

Stats {
  dev: 8675309,
  mode: 33206,
  nlink: 1,
  uid: 501,
  gid: 20,
  rdev: 0,
  blksize: 4096,
  ino: 13,
  size: 0,
  blocks: 0,
  atimeMs: 1570547350139547.2,
  mtimeMs: 1570547350139547.2,
  ctimeMs: NaN,
  birthtimeMs: NaN,
  atime: +051738-08-31T08:48:59.547Z,
  mtime: +051738-08-31T08:48:59.547Z,
  ctime: Invalid Date,
  birthtime: Invalid Date
}

Explicitly setting the atime, ctime, mtime and birthtime has not effect, and produces a similar result.

const now = new Date();
mockFS.file({
  content: '',
  atime: now,
  ctime: now,
  mtime: now,
  birthtime: now,
})
@yuraxdrumz
Copy link

yuraxdrumz commented Oct 11, 2019

Hey,
After reading in nodejs changelog, I saw a change in fs.stats. This is the pull request from the nodejs repo. Maybe its related.
EDIT: Checked on Manjaro Linux + node 12.10.0 and everything seems to be working.

@knightjdr
Copy link
Author

Thanks. I'm testing on OSX, but I'll try tonight on Linux and see if I get a different result.

It looks like that change you highlight is the issue. 12.9.0 works fine, but not 12.10.0 (or the latest 12.11.1).

@knightjdr
Copy link
Author

Same problem on Ubuntu 18.04.3 LTS, with Node 12.10.0.

@tschaub
Copy link
Owner

tschaub commented Oct 18, 2019

Fix published in mock-fs@4.10.2. Thanks @3cp.

taneliang added a commit to nusmodifications/nusmods that referenced this issue Mar 3, 2020
mtimeMs was returing nanoseconds instead of milliseconds.

See: tschaub/mock-fs#276
ZhangYiJiang pushed a commit to nusmodifications/nusmods that referenced this issue Mar 3, 2020
* Update CI to use Node 12

Our Docker setup already uses Node 12.

* Upgrade mock-fs dep to fix one test failure

mtimeMs was returing nanoseconds instead of milliseconds.

See: tschaub/mock-fs#276

* Fix nus-api concurrency test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants