firebase / superstatic

Superstatic: a static file server for fancy apps.
MIT License
1.1k stars 81 forks source link

TypeError: Cannot read properties of undefined (reading 'getTime') #468

Open Deleplace opened 3 months ago

Deleplace commented 3 months ago

Hello, thank you for the nice static web server.

I reported this bug in firebase-tools (firebase-cli) and I'm not sure of the root cause, but the error stacktrace involved this line of superstatic dereferencing an fs stats time object which happened to be undefined.

We (2 people) could reproduce this in macOS and Linux when using Node 22.

However, the bug seems to not occur when using Node 20.

I'm using superstatic 9.0.3 (as found in my system at /home/linuxbrew/.linuxbrew/Cellar/firebase-cli/13.8.3/libexec/lib/node_modules/firebase-tools/node_modules/superstatic/package.json).

Deleplace commented 3 months ago

The superstatic package.json says

"engines": {
    "node": "18 || 20"
}

so it might be a misconfiguration in firebase-tools to accept Node 22.

gkalpak commented 2 months ago

For anyone wondering, I believe the problem is that the mtime property is now initially defined on the Stat prototype (instead of on the Stat instance itself (due to https://github.com/nodejs/node/pull/50908).

As a result, the spread operator here does not include the mtime key (since the spread operator does not consider enumerable properties on the prototype).