-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cfg(Firebase): fix Firebase local serving (
serve
or emulators:start
)
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)
- Loading branch information
Showing
3 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
diff --git a/node_modules/superstatic/lib/providers/fs.js b/node_modules/superstatic/lib/providers/fs.js | ||
index 414d9fc..1975cd5 100644 | ||
--- a/node_modules/superstatic/lib/providers/fs.js | ||
+++ b/node_modules/superstatic/lib/providers/fs.js | ||
@@ -86,7 +86,14 @@ module.exports = function provider(options) { | ||
try { | ||
const stat = await multiStat(fullPathnames); | ||
return { | ||
- modified: stat.mtime.getTime(), | ||
+ /* | ||
+ * [LOCAL-PATCH] | ||
+ * With Node.js v22, `mtime` is undefined, due to it being initially defined on `Stat.prototype`, which | ||
+ * means that the spread operator in `multiStat()` will not propagate it. | ||
+ * See, also, https://github.com/firebase/superstatic/issues/468#issuecomment-2166883064. | ||
+ */ | ||
+ //modified: stat.mtime.getTime(), | ||
+ modified: Math.round(Number(stat.mtimeMs)), | ||
size: stat.size, | ||
etag: await fetchEtag(stat.pathname, stat), | ||
stream: fs.createReadStream(stat.pathname), |