From b1e8d17e7b85f59d58f0350f878757b632b280c6 Mon Sep 17 00:00:00 2001 From: Geri Date: Wed, 14 Dec 2022 23:37:15 +0100 Subject: [PATCH] Fix dumb invalid time value issue --- .gitignore | 1 + lib/core/etag.js | 9 ++++++++- package-lock.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b1c2f0735..6016dc897 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ npm-debug.log* .nyc_*/ .dir-locals.el .DS_Store +.idea/ \ No newline at end of file diff --git a/lib/core/etag.js b/lib/core/etag.js index d3cddedfc..bd4e20b48 100644 --- a/lib/core/etag.js +++ b/lib/core/etag.js @@ -1,7 +1,14 @@ 'use strict'; module.exports = (stat, weakEtag) => { - let etag = `"${[stat.ino, stat.size, stat.mtime.toISOString()].join('-')}"`; + let time; + try { + time = stat.mtime.toISOString(); + } catch (e) { + time = new Date().toISOString(); + } + + let etag = `"${[stat.ino, stat.size, time].join('-')}"`; if (weakEtag) { etag = `W/${etag}`; } diff --git a/package-lock.json b/package-lock.json index f538d5334..57b132164 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "tap": "^14.11.0" }, "engines": { - "node": ">=12" + "node": ">=12.16" } }, "node_modules/@babel/code-frame": {