Skip to content

Commit 5b9b9d5

Browse files
VHall1brophdawg11
andauthored
fix (remix-serve): fallback to default path if source maps aren't available when building stack trace (#8446)
Co-authored-by: Matt Brophy <[email protected]>
1 parent dc8f9bc commit 5b9b9d5

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/remix-serve/cli.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ process.env.NODE_ENV = process.env.NODE_ENV ?? "production";
2020

2121
sourceMapSupport.install({
2222
retrieveSourceMap: function (source) {
23-
// get source file with the `file://` prefix
24-
let match = source.match(/^file:\/\/(.*)$/);
23+
let match = source.startsWith("file://");
2524
if (match) {
2625
let filePath = url.fileURLToPath(source);
27-
return {
28-
url: source,
29-
map: fs.readFileSync(`${filePath}.map`, "utf8"),
30-
};
26+
let sourceMapPath = `${filePath}.map`;
27+
if (fs.existsSync(sourceMapPath)) {
28+
return {
29+
url: source,
30+
map: fs.readFileSync(sourceMapPath, "utf8"),
31+
};
32+
}
3133
}
3234
return null;
3335
},

0 commit comments

Comments
 (0)