oven-sh / bun

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

Bun crashes while using standalone NextJs Build with middleware #14496

Open SpectralAngel opened 1 week ago

SpectralAngel commented 1 week ago

What version of Bun is running?

1.1.30

What platform is your computer?

Docker image oven/bun:alpine

What steps can reproduce the bug?

Using Next.js 14.2.15 and next-auth@5.0.0-beta.22 bun crashes when the middleware is touched.

This was working with bun version 1.1.29

What is the expected behavior?

Serving pages normally

What do you see instead?

  ▲ Next.js 14.2.15
  - Local:        http://localhost:3000
  - Network:      http://0.0.0.0:3000
 ✓ Starting...
 ✓ Ready in 83ms
 ⨯  7 |   Read more: https://nextjs.org/docs/messages/middleware-new-signature
 8 |   `)}}class n extends Error{constructor(){super(`The request.page has been deprecated in favour of \`URLPattern\`.
 9 |   Read more: https://nextjs.org/docs/messages/middleware-request-page
10 |   `)}}class i extends Error{constructor(){super(`The request.ua has been removed in favour of \`userAgent\` function.
11 |   Read more: https://nextjs.org/docs/messages/middleware-parse-user-agent
12 |   `)}}},11658:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(t,{ImageResponse:function(){return n.ImageResponse},NextRequest:function(){return i.NextRequest},NextResponse:function(){return o.NextResponse},URLPattern:function(){return s.URLPattern},userAgent:function(){return a.userAgent},userAgentFromString:function(){return a.userAgentFromString}});let n=r(65949),i=r(79789),o=r(53780),a=r(14091),s=r(88847)},45693:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"NextURL",{enumerable:!0,get:function(){return u}});let n=r(96900),i=r(72084),o=r(57352),a=r(42150),s=/(?!^https?:\/\/)(127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|\[::1\]|localhost)/;function c(e,t){return new URL(String(e).replace(s,"localhost"),t&&String(t).replace(s,"localhost"))}let l=Symbol("NextURLInternal");class u{constructor(e,t,r){let n,i;"object"==typeof t&&"pathname"in t||"strin
TypeError: The Request.signal getter can only be used on instances of Request
      at new c (/app/.next/server/chunks/780.js:12:9511)
      at i4 (/app/.next/server/chunks/780.js:379:51587)
      at t (/app/.next/server/chunks/780.js:379:57541)
      at /app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:36962
      at /app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:29696
      at /app/node_modules/next/dist/server/lib/trace/tracer.js:140:36
      at run (node:async_hooks:82:6)
      at wrap (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:23166)
      at run (node:async_hooks:82:6)
      at wrap (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:20514)
      at run (node:async_hooks:82:6)
      at /app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:27581
      at execute (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:27337)
      at /app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:38301
      at handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:38278)
      at /app/node_modules/next/dist/server/base-server.js:1352:60
      at doRender (/app/node_modules/next/dist/server/base-server.js:1264:35)
      at /app/node_modules/next/dist/server/base-server.js:1574:34
      at /app/node_modules/next/dist/server/base-server.js:1482:77
      at get (/app/node_modules/next/dist/server/response-cache/index.js:46:15)
      at /app/node_modules/next/dist/server/base-server.js:1482:53

Additional information

No response

RiskyMH commented 1 week ago

This next-auth keeps on not working when I try to set it up, do you have a basic git repo that I can download and try to run instead (inc dockerfile)?

Also just to check, this works correctly with node right?

github-actions[bot] commented 1 week ago

Hello @SpectralAngel. Please provide a minimal reproduction using a GitHub repository, Replit, CodeSandbox, or provide a bulleted list of commands to run that reproduce this issue. Issues marked with needs repro will be closed if they have no activity within 3 days.

SpectralAngel commented 1 week ago

@RiskyMH yes this runs with node and with bun 1.1.29, I will upload a basic repo with the minimun required to make it crash

SpectralAngel commented 1 week ago

Here is the link to the repository, all you need to recreate the behavior is to run the docker-compose and point your browser to localhost:3000, you will be presented with a grey page and with the stack trace in the docker container https://github.com/SpectralAngel/bun-middleware-crash

RiskyMH commented 1 week ago

Thanks for confirming! I can now reproduce this crash too. The next step is to figure out the root cause, but thank you for reporting it and letting us know. It definitely helps to have this reproducible case to work with.

arno-fukuda commented 1 week ago

Also ran into this today. Same on oven/bun:canary-alpine

thakuad commented 1 day ago

Because of this issue i need to move back to npm for deployment through docker.

RiskyMH commented 1 day ago

@thakuad Sorry to hear that, however I don't see any reason why Bun can't be used to install dependencies, even if it's not the builder or runtime.

Was the problem because Bun was being used as the package manager, or was it possibly due to Node.js not being installed, causing Bun to be used for runtime instead?