withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.93k stars 2.49k forks source link

Dev server crashes: `fatal error: stack overflow` #12457

Closed cintek closed 3 days ago

cintek commented 5 days ago

Astro Info

├─ @astrojs/mdx@npm:3.1.9
│  ├─ Instances: 1
│  ├─ Version: 3.1.9
│  │ 
│  └─ Dependencies
│     ├─ @astrojs/markdown-remark@npm:5.3.0 → npm:5.3.0
│     ├─ @mdx-js/mdx@npm:^3.1.0 → npm:3.1.0
│     ├─ acorn@npm:^8.14.0 → npm:8.14.0
│     ├─ es-module-lexer@npm:^1.5.4 → npm:1.5.4
│     ├─ estree-util-visit@npm:^2.0.0 → npm:2.0.0
│     ├─ gray-matter@npm:^4.0.3 → npm:4.0.3
│     ├─ hast-util-to-html@npm:^9.0.3 → npm:9.0.3
│     ├─ kleur@npm:^4.1.5 → npm:4.1.5
│     ├─ rehype-raw@npm:^7.0.0 → npm:7.0.0
│     ├─ remark-gfm@npm:^4.0.0 → npm:4.0.0
│     ├─ remark-smartypants@npm:^3.0.2 → npm:3.0.2
│     ├─ source-map@npm:^0.7.4 → npm:0.7.4
│     ├─ unist-util-visit@npm:^5.0.0 → npm:5.0.0
│     └─ vfile@npm:^6.0.3 → npm:6.0.3
│
├─ @astrojs/sitemap@npm:3.2.1
│  ├─ Version: 3.2.1
│  │ 
│  └─ Dependencies
│     ├─ sitemap@npm:^8.0.0 → npm:8.0.0
│     ├─ stream-replace-string@npm:^2.0.0 → npm:2.0.0
│     └─ zod@npm:^3.23.8 → npm:3.23.8
│
├─ astro@npm:4.16.13
│  ├─ Version: 4.16.13
│  │ 
│  ├─ Exported Binaries
│  │  └─ astro
│  │ 
│  └─ Dependencies
│     ├─ @astrojs/compiler@npm:^2.10.3 → npm:2.10.3
│     ├─ @astrojs/internal-helpers@npm:0.4.1 → npm:0.4.1
│     ├─ @astrojs/markdown-remark@npm:5.3.0 → npm:5.3.0
│     ├─ @astrojs/telemetry@npm:3.1.0 → npm:3.1.0
│     ├─ @babel/core@npm:^7.26.0 → npm:7.26.0
│     ├─ @babel/types@npm:^7.26.0 → npm:7.26.0
│     ├─ @oslojs/encoding@npm:^1.1.0 → npm:1.1.0
│     ├─ @types/babel__core@npm:^7.20.5 → npm:7.20.5
│     ├─ @types/cookie@npm:^0.6.0 → npm:0.6.0
│     ├─ acorn@npm:^8.14.0 → npm:8.14.0
│     ├─ aria-query@npm:^5.3.2 → npm:5.3.2
│     ├─ axobject-query@npm:^4.1.0 → npm:4.1.0
│     ├─ boxen@npm:8.0.1 → npm:8.0.1
│     ├─ ci-info@npm:^4.0.0 → npm:4.0.0
│     ├─ clsx@npm:^2.1.1 → npm:2.1.1
│     ├─ common-ancestor-path@npm:^1.0.1 → npm:1.0.1
│     ├─ cookie@npm:^0.7.2 → npm:0.7.2
│     ├─ cssesc@npm:^3.0.0 → npm:3.0.0
│     ├─ deterministic-object-hash@npm:^2.0.2 → npm:2.0.2
│     ├─ devalue@npm:^5.1.1 → npm:5.1.1
│     ├─ diff@npm:^5.2.0 → npm:5.2.0
│     ├─ dlv@npm:^1.1.3 → npm:1.1.3
│     ├─ dset@npm:^3.1.4 → npm:3.1.4
│     ├─ es-module-lexer@npm:^1.5.4 → npm:1.5.4
│     ├─ esbuild@npm:^0.21.5 → npm:0.21.5
│     ├─ estree-walker@npm:^3.0.3 → npm:3.0.3
│     ├─ fast-glob@npm:^3.3.2 → npm:3.3.2
│     ├─ flattie@npm:^1.1.1 → npm:1.1.1
│     ├─ github-slugger@npm:^2.0.0 → npm:2.0.0
│     ├─ gray-matter@npm:^4.0.3 → npm:4.0.3
│     ├─ html-escaper@npm:^3.0.3 → npm:3.0.3
│     ├─ http-cache-semantics@npm:^4.1.1 → npm:4.1.1
│     ├─ js-yaml@npm:^4.1.0 → npm:4.1.0
│     ├─ kleur@npm:^4.1.5 → npm:4.1.5
│     ├─ magic-string@npm:^0.30.12 → npm:0.30.12
│     ├─ magicast@npm:^0.3.5 → npm:0.3.5
│     ├─ micromatch@npm:^4.0.8 → npm:4.0.8
│     ├─ mrmime@npm:^2.0.0 → npm:2.0.0
│     ├─ neotraverse@npm:^0.6.18 → npm:0.6.18
│     ├─ ora@npm:^8.1.1 → npm:8.1.1
│     ├─ p-limit@npm:^6.1.0 → npm:6.1.0
│     ├─ p-queue@npm:^8.0.1 → npm:8.0.1
│     ├─ preferred-pm@npm:^4.0.0 → npm:4.0.0
│     ├─ prompts@npm:^2.4.2 → npm:2.4.2
│     ├─ rehype@npm:^13.0.2 → npm:13.0.2
│     ├─ semver@npm:^7.6.3 → npm:7.6.3
│     ├─ sharp@npm:^0.33.3 → npm:0.33.3
│     ├─ shiki@npm:^1.22.2 → npm:1.23.0
│     ├─ tinyexec@npm:^0.3.1 → npm:0.3.1
│     ├─ unist-util-visit@npm:^5.0.0 → npm:5.0.0
│     ├─ vfile@npm:^6.0.3 → npm:6.0.3
│     ├─ which-pm@npm:^3.0.0 → npm:3.0.0
│     ├─ xxhash-wasm@npm:^1.0.2 → npm:1.0.2
│     ├─ yargs-parser@npm:^21.1.1 → npm:21.1.1
│     ├─ zod@npm:^3.23.8 → npm:3.23.8
│     ├─ @babel/plugin-transform-react-jsx@npm:^7.25.9 → npm:7.25.9 [b5b37]
│     ├─ @rollup/pluginutils@npm:^5.1.3 → npm:5.1.3 [b5b37]
│     ├─ debug@npm:^4.3.7 → npm:4.3.7 [b5b37]
│     ├─ tsconfck@npm:^3.1.4 → npm:3.1.4 [b5b37]
│     ├─ vite@npm:^5.4.10 → npm:5.4.11 [b5b37]
│     ├─ vitefu@npm:^1.0.3 → npm:1.0.3 [b5b37]
│     ├─ zod-to-json-schema@npm:^3.23.5 → npm:3.23.5 [b5b37]
│     └─ zod-to-ts@npm:^1.2.0 → npm:1.2.0 [b5b37]
│
├─ daten-diaet@workspace:.
│  ├─ Version: 0.0.1
│  │ 
│  └─ Dependencies
│     ├─ @astrojs/sitemap@npm:^3.2.0 → npm:3.2.1
│     ├─ astro@npm:^4.16.2 → npm:4.16.13
│     ├─ sharp@npm:^0.33.5 → npm:0.33.5
│     ├─ shikiji-core@npm:^0.10.2 → npm:0.10.2
│     ├─ typescript@patch:typescript@npm%3A^5.6.3#optional!builtin<compat/typescript> → patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=e012d7
│     └─ @astrojs/mdx@npm:^3.1.8 → npm:3.1.9 [6edeb]
│
├─ sharp@npm:0.33.5
│  ├─ Version: 0.33.5
│  │ 
│  └─ Dependencies
│     ├─ @img/sharp-darwin-arm64@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-darwin-x64@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-libvips-darwin-arm64@npm:1.0.4 → npm:1.0.4
│     ├─ @img/sharp-libvips-darwin-x64@npm:1.0.4 → npm:1.0.4
│     ├─ @img/sharp-libvips-linux-arm64@npm:1.0.4 → npm:1.0.4
│     ├─ @img/sharp-libvips-linux-arm@npm:1.0.5 → npm:1.0.5
│     ├─ @img/sharp-libvips-linux-s390x@npm:1.0.4 → npm:1.0.4
│     ├─ @img/sharp-libvips-linux-x64@npm:1.0.4 → npm:1.0.4
│     ├─ @img/sharp-libvips-linuxmusl-arm64@npm:1.0.4 → npm:1.0.4
│     ├─ @img/sharp-libvips-linuxmusl-x64@npm:1.0.4 → npm:1.0.4
│     ├─ @img/sharp-linux-arm64@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-linux-arm@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-linux-s390x@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-linux-x64@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-linuxmusl-arm64@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-linuxmusl-x64@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-wasm32@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-win32-ia32@npm:0.33.5 → npm:0.33.5
│     ├─ @img/sharp-win32-x64@npm:0.33.5 → npm:0.33.5
│     ├─ color@npm:^4.2.3 → npm:4.2.3
│     ├─ detect-libc@npm:^2.0.3 → npm:2.0.3
│     └─ semver@npm:^7.6.3 → npm:7.6.3
│
├─ shikiji-core@npm:0.10.2
│  └─ Version: 0.10.2
│
└─ typescript@patch:typescript@npm%3A5.6.3#optional!builtin<compat/typescript>::version=5.6.3&hash=e012d7
   ├─ Version: 5.6.3
   │ 
   └─ Exported Binaries
      ├─ tsc
      └─ tsserver

If this issue only occurs in one browser, which browser is a problem?

Appears in Firefox and Chromium-based browser.

Describe the Bug

What's the expected result?

The dev server should continue to work.

Link to Minimal Reproducible Example

https://codeberg.org/chikl/datendiaet/commit/9b3fb63107ba35ce2050c8955a653b7b5dd3f209

Additional information

Although I linked a commit with a non-up-to-date version of astro I can confirm that this problem also appears with the recent version of it.

Here are the changes between the last commit where the dev server didn't crash and the one where it started to crash: https://codeberg.org/chikl/datendiaet/commit/9b3fb63107ba35ce2050c8955a653b7b5dd3f209

In the browser I can see that requests were made to the following pages and these requests wait for an answer until the server crashes:

http://localhost:4321/node_modules/.vite/deps/astro___aria-query.js?v=f5ea5747
http://localhost:4321/node_modules/.vite/deps/astro___axobject-query.js?v=f5ea5747

The stack trace starts with

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc04ba003f0 stack=[0xc04ba00000, 0xc06ba00000]
fatal error: stack overflow

runtime stack:
runtime.throw({0x9c3f2a?, 0xcffc60?})
    runtime/panic.go:1047 +0x5d fp=0xc0000a1e18 sp=0xc0000a1de8 pc=0x4357dd
runtime.newstack()
    runtime/stack.go:1105 +0x5bd fp=0xc0000a1fc8 sp=0xc0000a1e18 pc=0x44fbfd
runtime.morestack()
    runtime/asm_amd64.s:574 +0x8b fp=0xc0000a1fd0 sp=0xc0000a1fc8 pc=0x467eab

goroutine 87 [running]:
github.com/evanw/esbuild/internal/fs.(*realFS).ReadDirectory.func1(0xc000040040?, {0xc0a6fe7830?, 0x27?})
    github.com/evanw/esbuild/internal/fs/fs_real.go:133 +0x22d fp=0xc04ba00400 sp=0xc04ba003f8 pc=0x7c0ead
github.com/evanw/esbuild/internal/fs.(*realFS).ReadDirectory(0xc000040040, {0xc0a6fe7830, 0x27})
    github.com/evanw/esbuild/internal/fs/fs_real.go:138 +0xa6 fp=0xc04ba00608 sp=0xc04ba00400 pc=0x7c0386

and ends with:

goroutine 147 [GC worker (idle)]:
runtime.gopark(0x941790fc87f?, 0x3?, 0x63?, 0xde?, 0x0?)
    runtime/proc.go:381 +0xd6 fp=0xc000438f50 sp=0xc000438f30 pc=0x438536
runtime.gcBgMarkWorker()
    runtime/mgc.go:1275 +0xf1 fp=0xc000438fe0 sp=0xc000438f50 pc=0x41a7f1
runtime.goexit()
    runtime/asm_amd64.s:1598 +0x1 fp=0xc000438fe8 sp=0xc000438fe0 pc=0x469e41
created by runtime.gcBgMarkStartWorkers
    runtime/mgc.go:1199 +0x25
13:04:03 [ERROR] [UnhandledRejection] Astro detected an unhandled rejection. Here's the stack trace:
Error: The service was stopped
    at /path_to_project/datendiaet/.yarn/unplugged/esbuild-npm-0.21.5-d85dfbc965/node_modules/esbuild/lib/main.js:993:26
    at responseCallbacks.<computed> (/path_to_project/datendiaet/.yarn/unplugged/esbuild-npm-0.21.5-d85dfbc965/node_modules/esbuild/lib/main.js:622:9)
    at Socket.afterClose (/path_to_project/datendiaet/.yarn/unplugged/esbuild-npm-0.21.5-d85dfbc965/node_modules/esbuild/lib/main.js:613:28)
    at Socket.emit (node:events:531:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
  Hint:
    Make sure your promises all have an `await` or a `.catch()` handler.
  Error reference:
    https://docs.astro.build/en/reference/errors/unhandled-rejection/
  Stack trace:
    at /path_to_project/datendiaet/.yarn/unplugged/esbuild-npm-0.21.5-d85dfbc965/node_modules/esbuild/lib/main.js:993:26
    at Socket.afterClose (/path_to_project/datendiaet/.yarn/unplugged/esbuild-npm-0.21.5-d85dfbc965/node_modules/esbuild/lib/main.js:613:28)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.handleUnhandledRejection (file:///path_to_project/datendiaet/.yarn/cache/astro-npm-4.16.2-d250b74938-ef41863c1b.zip/node_modules/astro/dist/vite-plugin-astro-server/plugin.js:46:23)
    at process.emit (/path_to_project/datendiaet/.pnp.cjs:12079:25)
    at throwUnhandledRejectionsMode (node:internal/process/promises:385:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)
ematipico commented 3 days ago

I don't get this issue with pnpm. I suspect that yarn is not installing the correct version of some package, in fact this log is fishy

➤ YN0007: │ esbuild@npm:0.21.5 must be built because it never has been before or the last one failed
➤ YN0007: │ sharp@npm:0.33.3 must be built because it never has been before or the last one failed
➤ YN0007: │ sharp@npm:0.33.5 must be built because it never has been before or the last one failed

Two versions of sharp?

cintek commented 3 days ago

@ematipico for some reason the yarn.lock states that astro needs the dependency sharp 0.33.3 which doesn't seem to be the correct version. Even after I removed the cache etc. of Yarn and installed all dependencies again this issue persisted. I can confirm that pnpm doesn't have this problem so I guess I will continue with pnpm. Thanks for your help!