Skip to content

Commit

Permalink
fix: catch stack trace fixing errors thrown in web containers (#12775)
Browse files Browse the repository at this point in the history
Although, the returned stack trace line number reported is unfixed, it's better than not having any useful errors reported.
  • Loading branch information
eltigerchino authored Oct 9, 2024
1 parent 13fb7f5 commit 5241d8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-games-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: catch stack trace fixing errors thrown in web containers
4 changes: 3 additions & 1 deletion packages/kit/src/exports/vite/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ export async function dev(vite, vite_config, svelte_config) {

/** @param {Error} error */
function fix_stack_trace(error) {
vite.ssrFixStacktrace(error);
try {
vite.ssrFixStacktrace(error);
} catch {}
return error.stack;
}

Expand Down
14 changes: 0 additions & 14 deletions packages/kit/src/runtime/server/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,3 @@ export function stringify_uses(node) {

return `"uses":{${uses.join(',')}}`;
}

/**
* @param {string} message
* @param {number} offset
*/
export function warn_with_callsite(message, offset = 0) {
if (DEV) {
const stack = fix_stack_trace(new Error()).split('\n');
const line = stack.at(3 + offset);
message += `\n${line}`;
}

console.warn(message);
}

0 comments on commit 5241d8a

Please sign in to comment.