oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.13k stars 2.67k forks source link

Bun fails to start development server for new Nuxt project WSL. #5598

Open PaoloTorregroza opened 12 months ago

PaoloTorregroza commented 12 months ago

What version of Bun is running?

1.0.2

What platform is your computer?

Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

What is the expected behavior?

Usually when you run a node project for the first time on windows it asks for firewall permissions, after you give them the app runs normally.

I think this is an issue with bun not asking windows for new firewall permissions when running under wsl.

What do you see instead?

MyMachine$ bun run dev
$ nuxt dev
Nuxt 3.7.3 with Nitro 2.6.3                                                                                                                                                                          6:08:45 PM
                                                                                                                                                                                                     6:08:46 PM
  ➜ Local:    http://127.0.0.1:3000/
  ➜ Network:  use --host to expose

✔ Nuxt DevTools is enabled v0.8.3 (experimental)                                                                                                                                                    6:09:00 PM
error: script "dev" exited with code 11 (SIGSEGV)

Additional information

No response

whiterqbbit commented 12 months ago

Same bug in Ubuntu 22.04, with bun 1.0.2. I also get this message

error: script "dev" exited with code 11 (SIGSEGV)

~/code/temp/bun_nuxt_test ❯ fatal error: all goroutines are asleep - deadlock!                                                                   11:31:45

goroutine 1 [chan receive]:
github.com/evanw/esbuild/internal/helpers.(*ThreadSafeWaitGroup).Wait(...)
        github.com/evanw/esbuild/internal/helpers/waitgroup.go:36
main.runService.func2()
        github.com/evanw/esbuild/cmd/esbuild/service.go:114 +0x59
main.runService(0x1)
        github.com/evanw/esbuild/cmd/esbuild/service.go:160 +0x4ed
main.main()
        github.com/evanw/esbuild/cmd/esbuild/main.go:240 +0xa29

goroutine 18 [chan receive]:
main.runService.func1()
        github.com/evanw/esbuild/cmd/esbuild/service.go:98 +0x4a
created by main.runService
        github.com/evanw/esbuild/cmd/esbuild/service.go:97 +0x1e5

goroutine 19 [chan receive]:
main.(*serviceType).sendRequest(0xc000121ec0, {0x915100, 0xc0000a2930})
        github.com/evanw/esbuild/cmd/esbuild/service.go:192 +0xfa
main.runService.func3()
        github.com/evanw/esbuild/cmd/esbuild/service.go:125 +0x39
created by main.runService
        github.com/evanw/esbuild/cmd/esbuild/service.go:122 +0x31c

goroutine 10 [chan receive]:
github.com/evanw/esbuild/internal/bundler.(*scanner).scanAllDependencies(0xc000252d80)
        github.com/evanw/esbuild/internal/bundler/bundler.go:1857 +0x232
github.com/evanw/esbuild/internal/bundler.ScanBundle(_, {_, _, _, _, _, _}, {_, _}, 0xc00028a240, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:1262 +0xb36
github.com/evanw/esbuild/pkg/api.rebuildImpl({0xc00028a240, {0xc000288180, 0x1, 0x1}, {0x0, 0x0, 0x0}, {0x0, 0x1, 0x2, ...}, ...}, ...)
        github.com/evanw/esbuild/pkg/api/api_impl.go:1501 +0x2e5
github.com/evanw/esbuild/pkg/api.(*internalContext).rebuild(_)
        github.com/evanw/esbuild/pkg/api/api_impl.go:1031 +0x2a5
github.com/evanw/esbuild/pkg/api.(*internalContext).Rebuild(0xc0000061a0?)
        github.com/evanw/esbuild/pkg/api/api_impl.go:1092 +0x58
main.(*serviceType).handleIncomingPacket.func5()
        github.com/evanw/esbuild/cmd/esbuild/service.go:293 +0xd5
created by main.(*serviceType).handleIncomingPacket
        github.com/evanw/esbuild/cmd/esbuild/service.go:290 +0x118d

goroutine 11 [chan receive]:
main.(*serviceType).sendRequest(0xc000121ec0, {0x915100, 0xc0002b52c0})
        github.com/evanw/esbuild/cmd/esbuild/service.go:192 +0xfa
main.(*serviceType).convertPlugins.func2.3({{0xc00029e120, 0x11}, {0xc0001b0e70, 0x70}, {0x98472c, 0x4}, {0xc0001b0e70, 0x55}, 0x2, {0x0, ...}})
        github.com/evanw/esbuild/cmd/esbuild/service.go:973 +0x768
github.com/evanw/esbuild/pkg/api.(*pluginImpl).onResolve.func1({{0xc00029e120, 0x11}, {0xc0001b0e70, 0x55}, {0x0, 0x0}, {{0xc0001b0e70, 0x70}, {0x98472c, 0x4}, ...}, ...})
        github.com/evanw/esbuild/pkg/api/api_impl.go:1936 +0x1f5
github.com/evanw/esbuild/internal/bundler.RunOnResolvePlugins({_, _, _}, _, {0xc0002361c0, 0xc000128180, 0xc000128198, 0xc000142020, 0x5, 0xc000284540}, ...)
        github.com/evanw/esbuild/internal/bundler/bundler.go:831 +0x8d5
github.com/evanw/esbuild/internal/bundler.parseFile({{0xa6f198, 0xc0001420e0}, {0xc0002361c0, 0xc000128180, 0xc000128198, 0xc000142020, 0x5, 0xc000284540}, 0xc000252900, 0xc00028a240, ...})
        github.com/evanw/esbuild/internal/bundler/bundler.go:397 +0x3187
created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile
7836246 commented 12 months ago

I've encountered this too, is there any solution?

PaoloTorregroza commented 12 months ago

I changed my windows network configuration, from Public Network to private network, deleted all lock files and node_modules and tried again using bun install && bun --bun run dev and got this new error.

MyMachine$ bun --bun run dev
$ nuxt dev
[1.86ms] ".env"
Nuxt 3.7.3 with Nitro 2.6.3                                                                                 8:55:17 AM
                                                                                                            8:55:19 AM
  ➜ Local:    http://127.0.0.1:3000/
  ➜ Network:  use --host to expose

✔ Nuxt DevTools is enabled v0.8.3 (experimental)                                                           8:55:33 AM

 ERROR  Cannot start nuxt:  {}
conduongtong commented 12 months ago

Same after upgrade to bun@1.0.2

dietler commented 11 months ago

I'm also getting this error on bun@1.0.2 on windows/WSL. But it worked fine with the base install of a nuxt app, it only appeared once I added tailwind and shadecn-vue

devendr4 commented 11 months ago

I'm getting the same error on bun 1.0.2 using Arch Linux on kernel 6.5.3-arch1-1

❯ bun --bun run dev
$ nuxt dev
Nuxt 3.7.3 with Nitro 2.6.3                                                                                                               5:54:18 PM
                                                                                                                                          5:54:19 PM
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ℹ Using default Tailwind CSS file                                                                                       nuxt:tailwindcss 5:54:19 PM
✔ Nuxt DevTools is enabled v0.8.3 (experimental)                                                                                         5:54:21 PM
ℹ Tailwind Viewer: http://127.0.0.1:47729/_tailwind/                                                                    nuxt:tailwindcss 5:54:21 PM
error: script "dev" exited with code 11 (SIGSEGV)

`

Running without--bun does work.

PaoloTorregroza commented 11 months ago

I'm getting the same error on bun 1.0.2 using Arch Linux on kernel 6.5.3-arch1-1

❯ bun --bun run dev
$ nuxt dev
Nuxt 3.7.3 with Nitro 2.6.3                                                                                                               5:54:18 PM
                                                                                                                                          5:54:19 PM
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ℹ Using default Tailwind CSS file                                                                                       nuxt:tailwindcss 5:54:19 PM
✔ Nuxt DevTools is enabled v0.8.3 (experimental)                                                                                         5:54:21 PM
ℹ Tailwind Viewer: http://127.0.0.1:47729/_tailwind/                                                                    nuxt:tailwindcss 5:54:21 PM
error: script "dev" exited with code 11 (SIGSEGV)

`

Running without--bun does work.

It works without --bun because if you omit that parameter bun is not going to be used to run some installed CLI tools (Check https://bun.sh/docs/cli/run#bun)

If you omit it node is going to be used to run those CLI tools

cax111 commented 11 months ago

refer to nuxt official documentation, you should run the web app like this : bun run dev -o hopefully it helps, but when I try run with the code above, I don't feel the different of time execution dev build

nathanchase commented 11 months ago

FWIW, this is working for me with bun 1.0.3, Nuxt 3.7.3 with Nitro 2.6.3, and nuxi 3.9.0.

Put this in your package.json:

"scripts": {
    "build": "NITRO_PRESET=bun bun --bun x nuxi build",
    "dev": "NITRO_PRESET=bun bun --bun x nuxi dev",
  },

and run bun dev and you should get a workng dev server... if you do not - try removing packages and/or Nuxt modules and see if one is causing the failure. I've seen some reports that @nuxt/content is one that causes failures for some - so start debugging there, if you're using that module.

bun run build also works, and the production server runs with bun run .output/server/index.mjs

alphaelf commented 11 months ago

FWIW, this is working for me with bun 1.0.3, Nuxt 3.7.3 with Nitro 2.6.3, and nuxi 3.9.0.

Put this in your package.json:

"scripts": {
    "build": "NITRO_PRESET=bun bun --bun x nuxi build",
    "dev": "NITRO_PRESET=bun bun --bun x nuxi dev",
  },

and run bun dev and you should get a workng dev server... if you do not - try removing packages and/or Nuxt modules and see if one is causing the failure. I've seen some reports that @nuxt/content is one that causes failures for some - so start debugging there, if you're using that module.

bun run build also works, and the production server runs with bun run .output/server/index.mjs

it run perfectly and works for hot reloaded pages and layouts but get below error for changes in nuxt.config.ts:

error: "nuxi" exited with code 11 (SIGSEGV)
error: script "dev" exited with code 11 (SIGSEGV)
David-Mueller commented 11 months ago

same issue here, with all proposed solutions.

"nuxi" exited with code 11 (SIGSEGV)

nuxt v3.7.4 bun 1.0.6 nuxi 3.9.0

BernhardRode commented 10 months ago

Had the same issue. Problem was that i had somehow a node_modules folder from "somewhere else".

Removed it, did a clean bun install and now the error is gone

cotneit commented 6 months ago

No longer an issue on bun 1.0.33 + Nuxt 3.11.0 with Nitro 2.9.4 under WSL

Tested several versions and it seems fix landed in bun 1.0.22 (on 1.0.21 it is consistently reproducible)