sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.43k stars 1.88k forks source link

build hangs indefinitely when symlinks get involved #7024

Open UltraCakeBakery opened 1 year ago

UltraCakeBakery commented 1 year ago

Describe the bug

I replaced the src and static folder in my project with symlinks that point to another cloned repository folder. This causes vite build to hang indefinitely at this step:

.svelte-kit/output/server/chunks/hooks.js 0.00 KiB

Code_b7MxVF1mEV

Reproduction

~Not sure how to provide a reproduction due to the usage of symlinks. You can however init the skeleton project template and replace the src and static directories with a symlinks. You should see that the step never completes like I showed in the gif / logs.~

EDIT: https://github.com/UltraCakeBakery/sveltekit-symlinks-issue

Logs

PS P:\reproductionn> pnpm build

> reproductionn@0.0.1 build P:\reproductionn
> vite build

vite v3.1.3 building for production...
✓ 30 modules transformed.
vite v3.1.3 building SSR bundle for production...
✓ 50 modules transformed.
Generated an empty chunk: "hooks"
.svelte-kit/output/server/vite-manifest.json                   1.41 KiB
.svelte-kit/output/server/index.js                             85.62 KiB
.svelte-kit/output/server/entries/fallbacks/layout.svelte.js   0.23 KiB
.svelte-kit/output/server/entries/fallbacks/error.svelte.js    1.50 KiB
.svelte-kit/output/server/entries/pages/_page.svelte.js        0.31 KiB
.svelte-kit/output/server/chunks/index.js                      3.10 KiB
.svelte-kit/output/server/chunks/hooks.js                      0.00 KiB
...

And then it just hangs. It never resolves / moves on to the next fase.

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Memory: 4.79 GB / 15.75 GB
  Binaries:
    Node: 16.15.1 - C:\Program Files\nodejs\node.EXE
    npm: 8.5.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (105.0.1343.50)
    Internet Explorer: 11.0.22000.120

Severity

blocking all usage of SvelteKit

Additional Information

None

UltraCakeBakery commented 1 year ago

Created a minimal reproduction using the skeleton template here: https://github.com/UltraCakeBakery/sveltekit-symlinks-issue

Today I learned git supports symlinks yay

UltraCakeBakery commented 1 year ago

Edited the issue so it is now based on the minimal reproduction. I hope these changes clear things up.

Nergy101 commented 1 year ago

Same here... No clue why it's hanging right after the "hooks". Tried different versions of node-adapter, etc.

Nothing new on this between then and now? Consider this a +1 :(

my deps:

"devDependencies": {
        "@smui/button": "^7.0.0-beta.0",
        "@smui/card": "^7.0.0-beta.0",
        "@smui/textfield": "^7.0.0-beta.0",
        "@sveltejs/adapter-node": "1.1.0",
        "@sveltejs/kit": "^1.0.0",
        "@tailwindcss/forms": "^0.5.3",
        "@types/express": "^4.17.15",
        "@types/rethinkdb": "^2.3.17",
        "@typescript-eslint/eslint-plugin": "^5.45.0",
        "@typescript-eslint/parser": "^5.45.0",
        "autoprefixer": "^10.4.13",
        "eslint": "^8.28.0",
        "eslint-config-prettier": "^8.5.0",
        "eslint-plugin-svelte3": "^4.0.0",
        "postcss": "^8.4.21",
        "prettier": "^2.8.0",
        "prettier-plugin-svelte": "^2.8.1",
        "smui-theme": "^7.0.0-beta.0",
        "svelte": "^3.54.0",
        "svelte-check": "^2.9.2",
        "tailwindcss": "^3.2.4",
        "tslib": "^2.4.1",
        "typescript": "^4.9.3",
        "vite": "^4.0.0"
    },
    "type": "module",
    "dependencies": {
        "express": "^4.18.2",
        "rethinkdb": "^2.4.2",
        "socket.io": "^4.5.4",
        "socket.io-client": "^4.5.4"
    }
netcodedev commented 1 year ago

I noticed that for some projects build would only run through if the database is up and reachable. For some reason sveltekit seems to initiate a database connection and will only finish building when that connection is successfull

UltraCakeBakery commented 1 year ago

I noticed that for some projects build would only run through if the database is up and reachable. For some reason sveltekit seems to initiate a database connection and will only finish building when that connection is successfull

It might be waiting endlessly on an unresolved query or never close the connection process, causing the on exit event to never be called, which in turn does not finish the build step. Not sure if that is actually how it works, but I've seen issues in the past related to database connections saying something similair. I think this is why there is that ugly line of code in the code base of svelte kit somewhere with process.exit() and a funny comment above it.

Nergy101 commented 1 year ago

I noticed that for some projects build would only run through if the database is up and reachable. For some reason sveltekit seems to initiate a database connection and will only finish building when that connection is successfull

It might be waiting endlessly on an unresolved query or never close the connection process, causing the on exit event to never be called, which in turn does not finish the build step. Not sure if that is actually how it works, but I've seen issues in the past related to database connections saying something similair. I think this is why there is that ugly line of code in the code base of svelte kit somewhere with process.exit() and a funny comment above it.

Hmm I do make a connection to my DB. Ill have a look later this week. Thx for the pointer. Dont like the setup for it anyways yet :).

Nergy101 commented 1 year ago

You were right @UltraCakeBakery .

After refactoring my code so I don't open a connection top-level in my JS/TS code, but per-need-basis, it stopped hanging. Thanks for the help!

UltraCakeBakery commented 1 year ago

This is still an issue in the most recent version of SvelteKit. I have updated the reproduction to use the latest versions of SvelteKit and vite. In the new version of vite, you now also need to add the symlinks pointer location to your allow serving list.

import { sveltekit } from '@sveltejs/kit/vite';

const config = {
    plugins: [sveltekit()],
    server: {
        fs: {
            // Allow serving files from one level up to the project root
            allow: ['./src-original', './static-original'],
        },
    },
};

export default config;