R
Railway12mo ago
Marc

Issue Deploying Next.js 13 with Bun 1.0

For better or worse I've decided to follow the hype train and am trying to get Bun 1.0 working with my Next.js 13 project on railway. Prior to using Bun the project has been deploying perfectly fine. I have followed the many threads already made here about Bun and am using the special Nixpkgs archive to make sure I have bun 1.0 available. The funky thing is the project actually appears to build fine. Meaning there are no errors during the build. An image is produced and then it's deployed. The error only occurs during actually running the app when I get the following error:
next start -p process.env.PORT
- ready started server on localhost:34497, url: http://localhost:34497
ENOENT: No such file or directory
path: "/app/.next/BUILD_ID"
syscall: "open"
errno: -2
next start -p process.env.PORT
- ready started server on localhost:34497, url: http://localhost:34497
ENOENT: No such file or directory
path: "/app/.next/BUILD_ID"
syscall: "open"
errno: -2
This causes the deployment to error out and consider itself "completed" not "active". I have tried building then running the package locally on my M2 macbook and it works fine. The only final clue I can offer is that weirdly the output during the build step is missing the Next.js route type output. That part where it tells you what route will be what. SSR, Static, etc. It appears on my local computer, but not during the build on railway and it definitely used to when using pure yarn/node. However, it again does not produce and error, there's just no output:
#12 0.445 $ next build
#12 1.659 - warn You have enabled experimental features (serverActions, serverComponentsExternalPackages) in next.config.js.

#12 1.659 - warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

#12 1.660
#12 1.943 - info Creating an optimized production build...
#12 DONE 30.9s


#13 [stage-0 9/10] RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile

#13 DONE 0.4s

#14 [stage-0 10/10] COPY . /app

#14 DONE 0.1s

#15 exporting to image
#15 exporting layers
#12 0.445 $ next build
#12 1.659 - warn You have enabled experimental features (serverActions, serverComponentsExternalPackages) in next.config.js.

#12 1.659 - warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.

#12 1.660
#12 1.943 - info Creating an optimized production build...
#12 DONE 30.9s


#13 [stage-0 9/10] RUN printf '\nPATH=/app/node_modules/.bin:$PATH' >> /root/.profile

#13 DONE 0.4s

#14 [stage-0 10/10] COPY . /app

#14 DONE 0.1s

#15 exporting to image
#15 exporting layers
52 Replies
Percy
Percy12mo ago
Project ID: d56d2d18-a224-4e42-89ad-f6d1f43b6b55
Marc
Marc12mo ago
d56d2d18-a224-4e42-89ad-f6d1f43b6b55
Marc
Marc12mo ago
Larger snippet of the build log
Marc
Marc12mo ago
Potentially related github issue on Bun: https://github.com/oven-sh/bun/issues/4795
GitHub
Bun + Nextjs + Docker: Incomplete .next build output in docker, but...
What version of Bun is running? 1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983 What platform is your computer? Linux 6.2.0-32-generic x86_64 x86_64 What steps can reproduce the bug? git clone git@g...
Brody
Brody12mo ago
not much we can do for you if this is a bun issue
Marc
Marc12mo ago
I'm not sure it's a bun issue persay. Again it works fine on my local machine, just on railway it seems like for whatever reason the proper Next.js files aren't built or put in the right place
Brody
Brody12mo ago
railway does use docker, and if bun isn't playing nicely in a docker environment there's again not much we can do for you here
Marc
Marc12mo ago
Are you aware of anyone getting Next.js and bun to work on railway because this is currently a blocker for me. That issue I pointed out might be the cause, but it was just something that seemed similar. I'm still worried I'm potentially doing something dumb.
Brody
Brody12mo ago
i am not aware of anyone who got Next.js and bun to work on railway
Marc
Marc12mo ago
Hmm that's interesting but to be clear I'm not directly using docker. I'm using Nixpacks. Hence why I'm asking for help here
Brody
Brody12mo ago
nixpacks uses docker
Marc
Marc12mo ago
I understand that, but then how would you implement this given there's no docker yml file https://stackoverflow.com/a/76898046/6575991? Is it something in Nixpack toml?
Stack Overflow
Dockerize next.js 13 docker-compose.yml
I'm building a next.js 13 app, I want to dockerize it. My docker file Dockerfile is working but now I want to use docker-compose.yml file to use my dockerfile. I tried old versions new versions light
Brody
Brody12mo ago
nixpacks runs npm run build if you have a build script in your package.json
Marc
Marc12mo ago
Hmm maybe I'm not understanding you or I wasn't clear in the beginning. But basically all I have changed is switching to Bun. Before that I was using no additional config on Railway. It detected it was a Next.js project and my build command is 'bun run build' and my start command is 'bun run start' with those mapping to: 'next build' and 'next start' respectively. Everything worked fine. I'm only sticking with this because I figured some other people may come across this issue as well. I'm not even sure what the issue is, but for whatever reason when the deploy step runs my start command it fails with my above error message
Want results from more Discord servers?
Add your server