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

SvelteKit alternative hooks path resolving problem #13184

Closed
p4wn-dev opened this issue Dec 17, 2024 · 1 comment · Fixed by #13188
Closed

SvelteKit alternative hooks path resolving problem #13184

p4wn-dev opened this issue Dec 17, 2024 · 1 comment · Fixed by #13188
Labels
bug Something isn't working

Comments

@p4wn-dev
Copy link

p4wn-dev commented Dec 17, 2024

Describe the bug

I have defined an alternative path for my server hook file in svelte.config.js, which is

[....]
files: { hooks: { server: 'src/hooks/hooks.server' } }
[....]

Since updating SvelteKit this does not work anymore and I get an internal server error. I provided the stack trace.
After tinkering around I found that if you create an empty universal hook file and add it to svelte.config.js like this:

files: { hooks: { server: 'src/hooks/hooks.server', universal: 'src/hooks/hooks' } }

Then it works.
Strangely adding a client hooks file does not work, only with a universal hooks file.

Did something change recently that I missed? I could not find anything related to this.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-llqwvuwy

Logs

Error: Failed to load url /src/hooks (resolved id: /src/hooks). Does the file exist?
    at loadAndTransform (file:///<project_path>/node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:40842:17) {
  code: 'ERR_LOAD_URL',
  runnerError: Error: RunnerError
      at reviveInvokeError (file:///<project_path>/node_modules/vite/dist/node/module-runner.js:545:18)
      at Object.invoke (file:///<project_path>/node_modules/vite/dist/node/module-runner.js:628:15)
      at async SSRCompatModuleRunner.getModuleInformation (file:///<project_path>/node_modules/vite/dist/node/module-runner.js:1200:73)
      at async request (file:///<project_path>/node_modules/vite/dist/node/module-runner.js:1222:88)
      at async get_hooks (<project_path>/.svelte-kit/generated/server/internal.js:44:28)
      at async eval (<project_path>/node_modules/@sveltejs/kit/src/runtime/server/index.js:82:20)
      at async Server.init (<project_path>/node_modules/@sveltejs/kit/src/runtime/server/index.js:80:3)
      at async file:///<project_path>/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:489:5

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Xeon(R) W-2225 CPU @ 4.10GHz
    Memory: 10.87 GB / 31.69 GB
  Binaries:
    Node: 22.6.0
    npm: 10.9.2
  Browsers:
    Edge: Chromium (131.0.2903.99)
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.3.1
    @sveltejs/adapter-node: ^5.2.9 => 5.2.10
    @sveltejs/kit: ^2.9.0 => 2.12.1
    @sveltejs/vite-plugin-svelte: ^5.0.0 => 5.0.2
    svelte: ^5.0.0 => 5.14.1
    vite: ^6.0.0 => 6.0.3

Severity

annoyance

Additional Information

UPDATE: Can confirm that the issue occurs from version 2.11.0 upwards.

No response

@paoloricciuti
Copy link
Member

I think this might be related to #13144

cc @eltigerchino

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants