kit icon indicating copy to clipboard operation
kit copied to clipboard

500 internal error using form actions from different directory when calling `fail()` (node.component is not a function)

Open higoka opened this issue 2 years ago • 3 comments

Describe the bug

When i return a fail() inside a form action which is in a different directory than the +page.svelte itself i throws an error saying TypeError: node.component is not a function

I have two identical +page.server.js files one inside /routes and one inside /routes/auth. It works as expected when the +page.server.js and +page.svelte files are inside the same directory. I believe it's because of the url changing after the form submission to /auth?/login so it tries to load the +page.svelte file from the /auth directory which there is not thus throwing the node.component is not a function error.

I hope its clear what i mean i also made a live demo here: https://sveltekit-auth-ruby.vercel.app/ The source code can be found here: https://github.com/higoka/sveltekit-auth

Reproduction

live demo: https://sveltekit-auth-ruby.vercel.app/ source code: https://github.com/higoka/sveltekit-auth

Logs

node.component is not a function
TypeError: node.component is not a function
    at file:///Users/nicorickenbach/Sites/sveltekit-auth/node_modules/@sveltejs/kit/src/runtime/server/page/render.js:82:64
    at Array.map (<anonymous>)
    at render_response (file:///Users/nicorickenbach/Sites/sveltekit-auth/node_modules/@sveltejs/kit/src/runtime/server/page/render.js:82:41)
    at render_page (file:///Users/nicorickenbach/Sites/sveltekit-auth/node_modules/@sveltejs/kit/src/runtime/server/page/index.js:299:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async resolve (file:///Users/nicorickenbach/Sites/sveltekit-auth/node_modules/@sveltejs/kit/src/runtime/server/index.js:356:17)
    at async respond (file:///Users/nicorickenbach/Sites/sveltekit-auth/node_modules/@sveltejs/kit/src/runtime/server/index.js:229:20)
    at async file:///Users/nicorickenbach/Sites/sveltekit-auth/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:444:22

System Info

System:
    OS: macOS 12.6.1
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 2.67 GB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 19.3.0 - /usr/local/bin/node
    npm: 9.2.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 108.0.5359.124
    Safari: 16.1
  npmPackages:
    @sveltejs/adapter-auto: ^1.0.0 => 1.0.0 
    @sveltejs/kit: ^1.0.0 => 1.0.1 
    svelte: ^3.54.0 => 3.55.0 
    vite: ^4.0.0 => 4.0.3

Severity

serious, but I can work around it

Additional Information

No response

higoka avatar Dec 28 '22 00:12 higoka

No bug, just a missing +page.svelte file in the authfolder. Found here: https://stackoverflow.com/a/73749620/8110291

KoljaL avatar Dec 28 '22 00:12 KoljaL

No it's hard to explain my englisch is not so good. The +page.svelte file is inside the /routes directory. What im trying to do is call the form action from a different directory /routes/auth

/routes/+page.svelte calls the form action from /routes/auth/+page.server.js

Is this even possible to have cross-directory form actions?

higoka avatar Dec 28 '22 00:12 higoka

Either add routes/auth/+page.svelte
or change to routes/auth/server.js

KoljaL avatar Dec 28 '22 01:12 KoljaL

The message TypeError: node.component is not a function is not very helpful. It could be improved.

wvhulle avatar Dec 30 '22 23:12 wvhulle