loadAll, lazy initClient and iOS / WebKit bug resulting in Error 500
ChrisSG opened this issue · comments
Describe the bug
Calling loadAll with export const ssr = false
results in an error 500, but only on ios.
I came to the conclusion that the behaviour of parallel fetching with loadAll results in calling initClient multiple times without awaiting the import of the client and thus initializing the let client = null
.
This results in a "Unhandled Promise Rejection: ReferenceError: Cannot access uninitialized variable."
Root cause would most probably be this bug in iOS / Safari combined with this behaviour: https://bugs.webkit.org/show_bug.cgi?id=242740
The question is if the behaviour of the code linked above is correct. On multiple calls on the same event-loop-level without awaiting the result - like loadAll
does - the client variable will not be initialized and the import will be triggered multiple times.
Also how does this interplay with sveltekit result streaming? (https://kit.svelte.dev/docs/load#streaming-with-promises)
Please be aware that due to the nature of the bug being only present on an iOS device I cannot easily provide a reproduction.
"houdini-svelte": "1.2.45",
"@sveltejs/kit": "1.21.0",
"svelte": "4.2.12",
WORKAROUND
// src/app.html
<script type="module" defer>
import { initClient } from '/$houdini/plugins/houdini-svelte/runtime/client';
await initClient();
</script>
%sveltekit.head%
Reproduction
No response
the variable that was causing the issue is now initialized to null
so the problem should be gone. i'm going to close this issue but feel free to let me know if the problem still persists and we can figure out what to do