Skip to content

Commit 483423f

Browse files
committed
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)
1 parent ff41fdc commit 483423f

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"eslint-import-resolver-typescript": "^3.6.1",
8080
"eslint-plugin-import": "^2.29.1",
8181
"eslint-plugin-jasmine": "^4.1.3",
82-
"firebase-tools": "^13.10.2",
82+
"firebase-tools": "^13.11.2",
8383
"hint": "^7.1.12",
8484
"jasmine-core": "^5.1.2",
8585
"karma": "^6.4.3",

patches/superstatic+9.0.3.patch

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/node_modules/superstatic/lib/providers/fs.js b/node_modules/superstatic/lib/providers/fs.js
2+
index 414d9fc..1975cd5 100644
3+
--- a/node_modules/superstatic/lib/providers/fs.js
4+
+++ b/node_modules/superstatic/lib/providers/fs.js
5+
@@ -86,7 +86,14 @@ module.exports = function provider(options) {
6+
try {
7+
const stat = await multiStat(fullPathnames);
8+
return {
9+
- modified: stat.mtime.getTime(),
10+
+ /*
11+
+ * [LOCAL-PATCH]
12+
+ * With Node.js v22, `mtime` is undefined, due to it being initially defined on `Stat.prototype`, which
13+
+ * means that the spread operator in `multiStat()` will not propagate it.
14+
+ * See, also, https://github.com/firebase/superstatic/issues/468#issuecomment-2166883064.
15+
+ */
16+
+ //modified: stat.mtime.getTime(),
17+
+ modified: Math.round(Number(stat.mtimeMs)),
18+
size: stat.size,
19+
etag: await fetchEtag(stat.pathname, stat),
20+
stream: fs.createReadStream(stat.pathname),

0 commit comments

Comments
 (0)