superstatic icon indicating copy to clipboard operation
superstatic copied to clipboard

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

Open Deleplace opened this issue 1 year ago • 2 comments

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 avatar May 16 '24 22:05 Deleplace

The superstatic package.json says

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

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

Deleplace avatar May 16 '24 22:05 Deleplace

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).

gkalpak avatar Jun 13 '24 22:06 gkalpak

Fixed by https://github.com/firebase/superstatic/pull/484 - published in 9.1.0

bkendall avatar Nov 13 '24 16:11 bkendall