bun icon indicating copy to clipboard operation
bun copied to clipboard

SegmentationFault in NextJS during load-testing

Open efosao opened this issue 2 years ago • 3 comments

Description

Bun exits with a SegmentationFault error when load-testing a default NextJS project.

Steps to replicate error

  1. Install new/default next project using bun create next test_proj command in terminal.
  2. To run app, cd into project dir and execute the bun dev command in terminal.
  3. If you don't have a load-tester handy, Siege can be installed using brew install siege command in terminal.
  4. Run load-test against project. eg. with siege I run the following - siege http://localhost:3000 -c 100

Result

Application will crash with SegmentationFault at 4611686014132420608 on MacOS (M1) or SegmentationFault at 0 on WSL.

efosao avatar Jul 08 '22 02:07 efosao

This is a bug, but I do not recommend bun dev for load testing of any kind

bun dev is not designed for production (hence "dev"). It's designed to be much faster than NodeJS-based dev servers, but it actually uses a completely different and much slower HTTP server than Bun.serve

Jarred-Sumner avatar Jul 08 '22 02:07 Jarred-Sumner

This is a bug, but I do not recommend bun dev for load testing of any kind

bun dev is not designed for production (hence "dev"). It's designed to be much faster than NodeJS-based dev servers, but it actually uses a completely different and much slower HTTP server than Bun.serve

Thanks for the info Jarred! Could you let me now how to run NextJS apps in Production Mode with Bun.serve? It's not clear to me from the docs how this works currently.

efosao avatar Jul 08 '22 07:07 efosao

My brief digging into this problem is most likely to occur when 404 occur.

$ mkdir foo
$ cd foo
$ bun dev

This always crash (for me)

$ mkdir foo
$ cd foo
$ touch index.html
$ bun dev

This does not occur. This is my guess, but the race condition may have occurred when "Connection: close" was returned.

mattn avatar Feb 11 '23 17:02 mattn

bun dev was changed in Bun v1.0, it will now run the "dev" script in your package.json. Because of that, this issue is no longer applicable.

Electroid avatar Oct 24 '23 21:10 Electroid