bun run build fails to complete
- Dominant language
- Go
- Stars
- 19.3k
- Forks
- 2k
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 264
Description
### Description
`bun run build` fails to complete in gVisor with `Next.js` version `14.2.20`.
There are already some known incompatibilities with Bun and gVisor. For example, Bun implements a workaround for the missing pidfd API in gVisor (https://github.com/google/gvisor/issues/5839). To try to address this incompatibility, I've partially implemented the api here: https://github.com/google/gvisor/compare/master...azliu0:gvisor:azliu/pidfd_open. This patch implements `pidfd_open`, which is the only syscall in the pidfd api used by bun; see [here](https://github.com/search?q=repo%3Aoven-sh%2Fbun%20%22linux.pidfd%22&type=code).
Unfortunately, even with this patch, the reproduction script below still fails, which leads me to believe that something else may be going on. I can't be sure that this is only a gVisor issue, so I've also opened https://github.com/oven-sh/bun/issues/16063. The reproduction script works with `runc` so it seems likely there's still something wrong with gVisor.
cc @pawalt
### Steps to reproduce
Dockerfile:
```
FROM oven/bun:latest
RUN apt-get update -yqq && \
apt-get install -yqq git && \
bun install -g turbo
WORKDIR /march
RUN git clone --depth 1 https://github.com/marchhq/march.git . && \
git fetch --depth 1 origin c0f0d196c4f7f94e10a66747be9bf96ce0135967 && \
git checkout -f FETCH_HEAD
RUN bun install
CMD ["bun", "run", "build"]
```
Then build the image and run with `runsc`.
**Expected behavior**: `bun run build` finishes relatively quickly.
**Observed behavior**: `bun run build` hangs at the step `Generating static pages (21/21)`.
On the [patched version](https://github.com/google/gvisor/compare/master...azliu0:gvisor:azliu/pidfd_open) that implements `pidfd_open`, I also observe `bun run build` hanging after a certain point, but the output looks different. A caveat is that the implementation in this patch may be incorrect, but it at least passes the tests in [`test/syscalls/linux/pidfd.cc`](https://github.com/azliu0/gvisor/blob/6f7092f37ad0242817878205cecc7dca8d4577b0/test/syscalls/linux/pidfd.cc).
I observe the expected behavior with `runc`.
### runsc version
```shell
runsc version release-20241217.0
spec: 1.1.0-rc.1
```
### docker version (if using docker)
```shell
Docker version 27.4.1, build b9d17ea
```
### uname
Linux ip-172-31-75-24 6.8.0-1018-aws #20-Ubuntu SMP Thu Oct 10 18:14:42 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
### kubectl (if using Kubernetes)
```shell
N/A
```
### repo state (if built from source)
N/A
### runsc debug logs (if available)
```shell
https://modal-public-assets.s3.us-east-1.amazonaws.com/vendor/bun-debug-logs.zip
```
Contributor guide
Assessment
This issue has not been assessed yet.