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

missing .svelte-kit/output/runtime/control.js file causes deno typechecks to fail #12930

Open
andykais opened this issue Oct 31, 2024 · 6 comments

Comments

@andykais
Copy link

Describe the bug

Since upgrading to deno 2, I am getting build failures using sveltekit. This seems to be because an autogenerated file .svelte-kit/output/server/index.js references a non existent file .svelte-kit/output/runtime/control.js (.svelte-kit/output/runtime/ doesnt appear to be a folder at all locally). The exact code referenced in index.js is this:

function normalize_error(error) {
  return (
    /** @type {import('../runtime/control.js').Redirect | HttpError | SvelteKitError | Error} */
    error
  );
}

I will be opening an issue on the deno side since this seems to be a runtime error despite this being a jsdoc comment which is confusing, but there is still something funky about a reference to a non existent file.

Reproduction

repro using this project here https://github.com/andykais/forager/tree/main/web. Steps to repro are below:

git clone git@github.com:andykais/forager.git
cd web
deno install
deno task build

Logs

`deno task build` (`deno run -A --unstable-ffi --check npm:vite build`) will produce the following output:

Check file:///Users/andrew.kaiser/Code/andykais/forager/web/.svelte-kit/output/server/manifest-full.js
error: Uncaught (in worker "") (in promise) TypeError: Module not found "file:///Users/andrew.kaiser/Code/andykais/forager/web/.svelte-kit/output/runtime/control.js".
    at file:///Users/andrew.kaiser/Code/andykais/forager/web/.svelte-kit/output/server/index.js:65:23
    at async prerender (file:///Users/andrew.kaiser/Code/andykais/forager/web/node_modules/.deno/@sveltejs+kit@2.5.28/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:36:21)
    at async file:///Users/andrew.kaiser/Code/andykais/forager/web/node_modules/.deno/@sveltejs+kit@2.5.28/node_modules/@sveltejs/kit/src/utils/fork.js:23:16
error: Uncaught (in promise) Error: Unhandled error. ([Object: null prototype] {
  message: 'Uncaught (in promise) TypeError: Module not found "file:///Users/andrew.kaiser/Code/andykais/forager/web/.svelte-kit/output/runtime/control.js".\n' +
    '    at \x1b[0m\x1b[36mfile:///Users/andrew.kaiser/Code/andykais/forager/web/.svelte-kit/output/server/index.js\x1b[0m:\x1b[0m\x1b[33m65\x1b[0m:\x1b[0m\x1b[33m23\x1b[0m',
  fileName: 'file:///Users/andrew.kaiser/Code/andykais/forager/web/node_modules/.deno/@sveltejs+kit@2.5.28/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js',
  lineNumber: 36,
  columnNumber: 21
})
    at NodeWorker.emit (ext:deno_node/_events.mjs:381:17)
    at NodeWorker.#handleError (node:worker_threads:117:10)
    at NodeWorker.#pollControl (node:worker_threads:137:30)
    at eventLoopTick (ext:core/01_core.js:175:7)


### System Info

```Shell
`deno --version` output:

deno 2.0.4 (stable, release, aarch64-apple-darwin)
v8 12.9.202.13-rusty
typescript 5.6.2

envinfo output:

  System:
    OS: macOS
    CPU: (10) arm64 Apple M1 Max
    Memory: 33.09 KB / 32.00 GB
    Shell: Unknown - /bin/zsh
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.2.5
    @sveltejs/kit: 2.7.3 => 2.5.28
    @sveltejs/vite-plugin-svelte: 4.0.0 => 4.0.0-next.7
    svelte: 5.1.3 => 5.0.0-next.251
    vite: 5.4.10 => 5.4.6


### Severity

blocking an upgrade

### Additional Information

_No response_
@andykais
Copy link
Author

actually it looks like this issue is already known on the deno side denoland/deno#26155. It sounds like the consensus is that deno is doing the "correct" thing when disabling typechecking. I think deno could be more lenient on these deep library errors, but I would still push that fixing this incorrect typing on the sveltekit side would unblock a lot of deno + sveltekit users

@eltigerchino
Copy link
Member

Please provide a minimal reproduction instead of a link to your project.

@andykais
Copy link
Author

Sure. This has a paired down version of the issue https://github.com/andykais/sveltekit-deno-build-bug-repro. I needed to include my custom deno adapter mainly just because I need to trigger the vite build to actually output the sveltekit files. The adapter code has been paired down as well. Cc @eltigerchino

@andykais
Copy link
Author

I attached a bit more info on the bug. If its helpful, I can separate the commits between what sv create generates and the changes I needed to make to recreate the bug afterwards too

@eltigerchino
Copy link
Member

eltigerchino commented Nov 12, 2024

I'm unable to reproduce the issue with the given reproduction. Below are the full logs / commands I've used. Note: I had to specifically run deno install --allow-scripts=npm:@sveltejs/kit@2.8.0 to get the npm postInstall script to run.

❯ git clone git@github.com:andykais/sveltekit-deno-build-bug-repro.git
cd sveltekit-deno-build-bug-repro
deno run --check npm:vite build
Cloning into 'sveltekit-deno-build-bug-repro'...
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 38 (delta 3), reused 37 (delta 2), pack-reused 0 (from 0)
Receiving objects: 100% (38/38), 32.83 KiB | 146.00 KiB/s, done.
Resolving deltas: 100% (3/3), done.
error: Could not find "vite" in a node_modules folder. Deno expects the node_modules/ directory to be up to date. Did you forget to run `deno install`?

~/github/sveltekit-deno-build-bug-repro main
❯ deno install --allow-scripts=npm:@sveltejs/kit@2.8.0

~/github/sveltekit-deno-build-bug-repro main*
❯ deno run --check npm:vite build
✅ Granted all env access.
✅ Granted all read access.
✅ Granted all sys access.
✅ Granted all write access.
Check file:///home/chewteeming/github/sveltekit-deno-build-bug-repro/vite.config.ts.timestamp-1731378330493-fc4e924358a7d.mjs
error during build:
TypeError: Relative import path "esbuild" not prefixed with / or ./ or ../
  hint: If you want to use a JSR or npm package, try running `deno add jsr:esbuild` or `deno add npm:esbuild`
    at file:///home/chewteeming/github/sveltekit-deno-build-bug-repro/adapter/adapter.js:4:21
    at async load_config (file:///home/chewteeming/github/sveltekit-deno-build-bug-repro/node_modules/.deno/@sveltejs+kit@2.8.0/node_modules/@sveltejs/kit/src/core/config/index.js:71:17)
    at async sveltekit (file:///home/chewteeming/github/sveltekit-deno-build-bug-repro/node_modules/.deno/@sveltejs+kit@2.8.0/node_modules/@sveltejs/kit/src/exports/vite/index.js:131:24)
    at async Promise.all (index 0)
    at async asyncFlatten (file:///home/chewteeming/github/sveltekit-deno-build-bug-repro/node_modules/.deno/vite@5.4.11/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:17501:12)
    at async resolveConfig (file:///home/chewteeming/github/sveltekit-deno-build-bug-repro/node_modules/.deno/vite@5.4.11/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:66166:27)
    at async build (file:///home/chewteeming/github/sveltekit-deno-build-bug-repro/node_modules/.deno/vite@5.4.11/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:65237:18)
    at async CAC.<anonymous> (file:///home/chewteeming/github/sveltekit-deno-build-bug-repro/node_modules/.deno/vite@5.4.11/node_modules/vite/dist/node/cli.js:828:5)

@eltigerchino
Copy link
Member

Possibly related #12986

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

No branches or pull requests

2 participants