-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When returning a promise from the load function that resolves to an object requiring serialization through transport, I encounter the following error:
Uncaught ReferenceError: app is not defined
However, if the promise is awaited inside the load function and the object is returned directly, the error does not occur.
I temporarily fixed the issue by importing app, but I have no familiarity with SvelteKit's internals, so I'm not sure if this solution makes sense. However, this is the commit that resolved it for me: dioguyto@d2fa756
Reproduction
Reproduction
// +page.server.ts
export const load: PageServerLoad = async (event) => {
const data = new Promise<TestEntity>((resolve) => {
resolve(new TestEntity({ name: "Test" }));
});
// If you await the promise and return the object directly, the error does not occur:
// const data = new TestEntity({ name: "Test" });
return {
data,
};
};
//+page.svelte
<script lang="ts">
import type { PageProps } from "./$types";
let { data }: PageProps = $props();
let { data: content } = data;
</script>
{#await content}
<p>Loading...</p>
{:then content}
<p>Data: {content.name}</p>
{:catch error}
<p style="color: red">{error.message}</p>
{/await}
Logs
16:27:12.798 Uncaught ReferenceError: app is not defined
<anonymous> http://localhost:5173/test:785
test:785:39
<anonymous> http://localhost:5173/test:785
This `http://localhost:5173/test:785` points to this line -> `<script>__sveltekit_dev.resolve({id:1,data:app.decode('Entity', [{name:"Test",_className:"TestEntity"}]),error:void 0})</script>`
System Info
System:
OS: Linux 6.13 cpe:/o:nixos:nixos:25.05 25.05 (Warbler)
CPU: (12) x64 AMD Ryzen 5 6600H with Radeon Graphics
Memory: 7.74 GB / 14.82 GB
Container: Yes
Shell: 0.101.0 - /run/current-system/sw/bin/nu
Binaries:
Node: 20.18.1 - /nix/store/wfxq6w9bkp5dcfr8yb6789b0w7128gnb-nodejs-20.18.1/bin/node
npm: 10.8.2 - /nix/store/wfxq6w9bkp5dcfr8yb6789b0w7128gnb-nodejs-20.18.1/bin/npm
pnpm: 9.14.4 - /nix/store/ic59mcqzsvrk7j24rqs9c6fscp9migd5-pnpm-9.14.4/bin/pnpm
Browsers:
Chromium: 132.0.6834.159
npmPackages:
@sveltejs/adapter-node: ^5.2.12 => 5.2.12
@sveltejs/kit: ^2.17.1 => 2.17.1
@sveltejs/vite-plugin-svelte: ^5.0.3 => 5.0.3
svelte: ^5.0.0 => 5.19.5
vite: ^6.0.0 => 6.0.11
Severity
annoyance
Additional Information
No response
jamesbirtles, helporme, caburum and OTheNonEwizmer, jchild3rs, OfficialHalfwayDead, patte, colecrouter and 1 morecolecrouter
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working