oven-sh / bun

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

Bun crashes when performing fs.createReadStream in express app #13980

Open ridhwaans opened 2 months ago

ridhwaans commented 2 months ago

How can we reproduce the crash?

1) create a /src/index.ts with the following express app

import express from 'express';
import fs from 'fs';

const app = express();
const router = express.Router();

router.get('/', (req, res) => {
  res.send('Hello World');
});

router.get('/video', async (req, res) => {
  // call  this readStream method https://gist.github.com/paolorossi/1993068
});

app.use(router);

const PORT = 3004;
app.listen(PORT, () => {
  console.log(`Listening on http://localhost:${PORT}`);
});

2) Create a bun dev command

"dev": "bun --watch run src/index.ts"

3) Run bun dev and go to localhost:3004/video

Expected the a html video element to play the video.
Instead the backend crashes with the logged output below.
Hard to say if it is a issue with the headers or file

It also crashes sometimes when videoRef.current.currentTime is scrubbed on the client

const videoRef = useRef<HTMLVideoElement>(null)

Relevant log output

error

panic(main thread): A C++ exception occurred
oh no: Bun has crashed. This indicates a bug in Bun, not your code.
...
error: script "dev" was terminated by signal SIGILL (Illegal instruction)

Stack Trace (bun.report)

Bun v1.1.10 (5102a94) on linux x86_64 [AutoCommand]

panic: A C++ exception occurred

github-actions[bot] commented 2 months ago

@ridhwaans, the latest version of Bun is v1.1.27, but this crash was reported on Bun v1.1.10.

Are you able to reproduce this crash on the latest version of Bun?

bun upgrade
ridhwaans commented 2 months ago

updated to 1.1.27 and the issue persists

Jarred-Sumner commented 2 months ago

Unfortunately, we will need a complete reproduction that ideally includes the video file for us to reproduce this.

github-actions[bot] commented 2 months ago

Hello @ridhwaans. Please provide a minimal reproduction using a GitHub repository, Replit, or CodeSandbox. Issues marked with needs repro will be closed if they have no activity within 3 days.

ridhwaans commented 3 weeks ago

@Jarred-Sumner

# https://github.com/ridhwaans/test-express/
git clone git@github.com:ridhwaans/test-express.git

unfortunately i cannot share the file due to copyright issue

it might be a codec issue, probably can test different files in the public domain