Skip to content

Commit

Permalink
stacktrace is unreliable
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Nov 27, 2022
1 parent df1b4be commit 6c5e4d0
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions packages/kit/src/runtime/client/fetcher.js
Expand Up @@ -13,21 +13,10 @@ export function unlock_fetch() {
}

if (import.meta.env.DEV) {
let can_inspect_stack_trace = false;

const check_stack_trace = async () => {
const stack = /** @type {string} */ (new Error().stack);
can_inspect_stack_trace = stack.includes('check_stack_trace');
};

check_stack_trace();

window.fetch = (input, init) => {
const url = input instanceof Request ? input.url : input.toString();
const stack = /** @type {string} */ (new Error().stack);

const heuristic = can_inspect_stack_trace ? stack.includes('load_node') : loading;
if (heuristic) {
if (loading) {
console.warn(
`Loading ${url} using \`window.fetch\`. For best results, use the \`fetch\` that is passed to your \`load\` function: https://kit.svelte.dev/docs/load#making-fetch-requests`
);
Expand Down

0 comments on commit 6c5e4d0

Please sign in to comment.