File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
packages/kit/src/runtime/client Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @sveltejs/kit ' : patch
3+ ---
4+
5+ [ fix] no false positive warnings for fetch uses in firefox
Original file line number Diff line number Diff line change @@ -24,12 +24,20 @@ if (DEV) {
2424 check_stack_trace ( ) ;
2525
2626 window . fetch = ( input , init ) => {
27+ // Check if fetch was called via load_node. the lock method only checks if it was called at the
28+ // same time, but not necessarily if it was called from `load`.
29+ // We use just the filename as the method name sometimes does not appear on the CI.
2730 const url = input instanceof Request ? input . url : input . toString ( ) ;
28- const stack = /** @type {string } */ ( new Error ( ) . stack ) ;
31+ const stack_array = /** @type {string } */ ( new Error ( ) . stack ) . split ( '\n' ) ;
32+ // We need to do some Firefox-specific cutoff because it (impressively) maintains the stack
33+ // across events and for example traces a `fetch` call triggered from a button back
34+ // to the creation of the event listener and the element creation itself,
35+ // where at some point client.js will show up, leading to false positives.
36+ const firefox_cutoff = stack_array . findIndex ( ( a ) => a . includes ( '*listen@' ) ) ;
37+ const stack = stack_array
38+ . slice ( 0 , firefox_cutoff !== - 1 ? firefox_cutoff : undefined )
39+ . join ( '\n' ) ;
2940
30- // check if fetch was called via load_node. the lock method only checks if it was called at the
31- // same time, but not necessarily if it was called from `load`
32- // we use just the filename as the method name sometimes does not appear on the CI
3341 const heuristic = can_inspect_stack_trace
3442 ? stack . includes ( 'src/runtime/client/client.js' )
3543 : loading ;
You can’t perform that action at this time.
0 commit comments