Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render error when using "$app/state" #49

Open
directormac opened this issue Jan 28, 2025 · 6 comments
Open

Render error when using "$app/state" #49

directormac opened this issue Jan 28, 2025 · 6 comments

Comments

@directormac
Copy link

TypeError: __vite_ssr_import_8__.page.subscribe is not a function
TypeError: __vite_ssr_import_8__.page.subscribe is not a function
    at _layout (/web/src/routes/+layout.svelte:19:6)
    at Root (/web/.svelte-kit/generated/root.svelte:63:3)
    at render (/web/node_modules/svelte/src/internal/server/index.js:115:2)
    at Function._render [as render] (/web/node_modules/svelte/src/legacy/legacy-server.js:27:24)
    at render_response (/web/node_modules/@sveltejs/kit/src/runtime/server/page/render.js:187:29)
    at async render_page (/web/node_modules/@sveltejs/kit/src/runtime/server/page/index.js:305:10)
    at async resolve (/web/node_modules/@sveltejs/kit/src/runtime/server/respond.js:457:18)
    at async auth (/web/src/hooks.server.ts:43:10)
    at async respond (/web/node_modules/@sveltejs/kit/src/runtime/server/respond.js:330:20)
    at async file:/web/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:521:22

Versions

		"svelte": "^5.19.4",
		"sveltekit-flash-message": "^2.4.6",
		"@sveltejs/kit": "^2.16.1",
@ciscoheat
Copy link
Owner

Try deleting node_modules, reinstall them and restart VS Code.

@directormac
Copy link
Author

Hi @ciscoheat i did try that already,

Things to note idk if it affects it but i tired using both adapter-auto and adapter-node, still that same error pops up.

@ciscoheat
Copy link
Owner

@directormac
Copy link
Author

Ah i see the problem now. it conflicts with houdini client.
where by default it exports it's own load on the root +layout.server.ts

Error: Transform failed with 1 error:
/web/src/routes/+layout.server.ts:10:9: ERROR: Multiple exports with the same name "load"
  errors: [
    {
      detail: undefined,
      id: '',
      location: [Object],
      notes: [Array],
      pluginName: '',
      text: 'Multiple exports with the same name "load"'
    }
  ],
  warnings: [],
  frame: '\n' +
    '\x1B[33mMultiple exports with the same name "load"\x1B[39m\n' +
    '8  |  }\n' +
    '9  |  \n' +
    '10 |  export { load } from "sveltekit-flash-message/server";\n' +
    '   |           ^\n',
  loc: {
    file: 'web/src/routes/+layout.server.ts',
    line: 10,
    column: 5
  },
  plugin: 'vite:esbuild',
  id: 'web/src/routes/+layout.server.ts',
  pluginCode: 'import { buildSessionObject } from "$houdini/plugins/houdini-svelte/runtime/session";\n' +
    '\n' +
    'export async function load(event) {\n' +
    '    return {\n' +
    '        ...buildSessionObject(event),\n' +
    '        ...{}\n' +
    '    };\n' +
    '}\n' +
    '\n' +
    'export { load } from "sveltekit-flash-message/server";',
  runnerError: Error: RunnerError

When i use this

export { load } from 'sveltekit-flash-message/server';

So i opted into using the flash, like this

import { loadFlash, flashCookieOptions } from 'sveltekit-flash-message/server';
flashCookieOptions.sameSite = 'lax';
export const load = loadFlash(async () => {});

I think it's doing it's error because this is being overriden by the houdini plugin, because that error went away.

Still doing "$app/state" import of page and loading it to flash gives me the original error, but not when importing the page from "$app/store".

@benquan
Copy link

benquan commented Jan 30, 2025

I have similar issue, the $app/store has been deprecated. I am trying to refactor my existing working code, but the code const flash = getFlash(page); is refering to the actual store and not the subscription $page. So how should we reference it if we change to $app/state?

@maumercado
Copy link

Having a similar issue using page from $app/state instead of page from $app/store. If using page from $app/state I don't get the flashing alert I set up unless I refresh the page, or navigate away, however with page from $app/store everything works as is, I assume there's some kind of subscription to be sent to getFlash in order for this to work with $app/state as its the preferred behaviour for svelte 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants