Skip to content

Commit c17b4c9

Browse files
authored
feat: redact internal stack trace when reporting config errors (#11292)
* feat: redact internal stack trace when reporting config errors * lint --------- Co-authored-by: Rich Harris <[email protected]>
1 parent 04fecb7 commit c17b4c9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

.changeset/smart-crabs-lick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': minor
3+
---
4+
5+
feat: redact internal stack trace when reporting config errors

packages/kit/src/core/config/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ export async function load_config({ cwd = process.cwd() } = {}) {
6969

7070
const config = await import(`${url.pathToFileURL(config_file).href}?ts=${Date.now()}`);
7171

72-
return process_config(config.default, { cwd });
72+
try {
73+
return process_config(config.default, { cwd });
74+
} catch (e) {
75+
const error = /** @type {Error} */ (e);
76+
77+
// redact the stack trace — it's not helpful to users
78+
error.stack = `Could not load svelte.config.js: ${error.message}\n`;
79+
throw error;
80+
}
7381
}
7482

7583
/**

0 commit comments

Comments
 (0)