webpack/webpack-cli

Timestamp in verbose logs is incorrect by a factor of 1000x

ryanwilsonperkin opened this issue · 1 comments

Describe the bug

When running webpack build --watch with an infrastructure log level of debug, any time a file is changed a log line will be emitted that specifies which file changed and what the time was of the change. This time is incorrect because of a calculation on the initial timestamp, causing the real datetime Changed time is Fri Apr 8 2022 09:56:00 EST-0400 (Eastern Daylight Time) to be reported as Changed time is Mon Mar 26 54238 16:04:29 GMT-0400 (Eastern Daylight Time)

What is the current behavior?

Reports a datetime that is tens of thousands of years in the future 😄

To Reproduce

Here's a minimal reproduction: https://gist.github.com/ryanwilsonperkin/9b14fcc354e6c24df99c9985e1fa5ccd

Steps to reproduce the behavior:

  1. Set infrastructure logging level to debug
  2. Run a build in watch mode
  3. Modify one of the entry files to trigger a recompile
  4. Note that the modified datetime that is specified in the resulting log will be incorrect

Expected behavior

Expected the datetime to be accurate

Screenshots

image

Image alt text from terminal
~/src/github.com/ryanwilsonperkin/webpack-watch-timestamp-bug main*
❯ yarn webpack build --watch
yarn run v1.22.17
$ /Users/ryan/src/github.com/ryanwilsonperkin/webpack-watch-timestamp-bug/node_modules/.bin/webpack build --watch
    [webpack-cli] Compiler starting...
    [webpack-cli] Compiler is using config: '/Users/ryan/src/github.com/ryanwilsonperkin/webpack-watch-timestamp-bug/webpack.config.js'
asset main.js 1.2 KiB [compared for emit] (name: main)
./index.js 28 bytes [built] [code generated]
webpack 5.72.0 compiled successfully in 47 ms
    [webpack-cli] Compiler finished
    [webpack-cli] Compiler is watching files for updates...
    [webpack-cli] File '/Users/ryan/src/github.com/ryanwilsonperkin/webpack-watch-timestamp-bug/index.js' was modified
    [webpack-cli] Changed time is Mon Apr 02 54238 08:02:55 GMT-0400 (Eastern Daylight Time) (timestamp is 1649426673775)
    [webpack-cli] Compiler starting...
    [webpack-cli] Compiler is using config: '/Users/ryan/src/github.com/ryanwilsonperkin/webpack-watch-timestamp-bug/webpack.config.js'
assets by status 1.2 KiB [cached] 1 asset
./index.js 28 bytes [built]
webpack 5.72.0 compiled successfully in 9 ms
    [webpack-cli] Compiler finished
    [webpack-cli] Compiler is watching files for updates...


Please paste the results of npx webpack-cli info here, and mention other relevant information

  System:
    OS: macOS 12.3.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 81.55 MB / 16.00 GB
  Binaries:
    Node: 17.2.0 - /opt/homebrew/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.1.4 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 100.0.4896.75
    Firefox: 95.0.1
    Safari: 15.4
  Packages:
    webpack: ^5.72.0 => 5.72.0
    webpack-cli: ^4.9.2 => 4.9.2

Additional context

HI @ryanwilsonperkin,
Yeah, those dates are crazy 😄 .
Thanks for the Issue and Pull request.