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

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

Closed
Deleplace opened this issue May 16, 2024 · 3 comments
Closed

Comments

@Deleplace
Copy link

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
Copy link
Author

The superstatic package.json says

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

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

@gkalpak
Copy link

gkalpak commented Jun 13, 2024

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 nodejs/node#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 added a commit to gkalpak/simple-torch that referenced this issue Jun 13, 2024
Due to a [breaking change][1] in Node.js v22, `superstatic`, the local
server used by Firebase `serve` and `emulators:start` commands throws an
error. See, also, [firebase/superstatic#468 (comment)][2] for details.

Apply a local patch to fix the issue, by accessing a property that is
defined on the `Stat` instance and thus will be available. We currently
do not need or use Firebase local serving, but I figured out the fix,
so... ¯\\\_(ツ)_/¯

[1]: nodejs/node#50908
[2]: firebase/superstatic#468 (comment)
@bkendall
Copy link
Collaborator

Fixed by #484 - published in 9.1.0

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