Description
How can we reproduce the crash?
I implemented two seprate Bun.server http servers one for websocket and other for http requests.
when i try to hit websocket server it works fine untile I do not call ws.subscribe I am passing a string in format text:number:number
(eg me:1:3
) on this line bun crashes and restart server again and again. some times it crash when app try to establish connection with DB using postgres on connect it crashes.
one more important point I found I am using nginx server
when I comment these lines websocket crashes
proxy_pass http://js-container:3010;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
uncommenting these line websocket works fine
proxy_pass http://js-container:3010;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
Also I am facing memory leakage problem in my application just wrting single line of code bunjs consuming 10MB of memory
I am call a function here is code
user = await getUserRoleBy(claims["sub"]); here is function
export function getUserRoleBy(user_id:number) {
return []
}
after the above line bunjs increase memory from 65MB to 79MB or 85MB
here is some code if it helps
js-container | Bun v1.2.17 (282dda62) Linux x64 (baseline)
js-container | WSL Kernel v5.15.167 | glibc v2.36
js-container | CPU: sse42 popcnt avx avx2
js-container | Args: "bun" "--env-file=.env.dev" "--bun" "run" "--watch" "index.ts"
js-container | Features: Bun.stderr(2) Bun.stdin(2) Bun.stdout(2) dotenv(2) http_server(2) jsc tsconfig(17) tsconfig_paths postgres_connections(5)
js-container | Builtins: "bun:main" "node:assert" "node:buffer" "node:child_process" "node:crypto" "node:dns" "node:events" "node:fs" "node:http" "node:https" "node:net" "node:os" "node:path" "node:process" "node:querystring" "node:stream" "node:tls" "node:tty" "node:url" "node:util" "node:zlib" "node-fetch"
js-container | Elapsed: 10958ms | User: 24257ms | Sys: 18080ms
js-container | RSS: 1.01GB | Peak: 118.01MB | Commit: 1.01GB | Faults: 663
js-container |
js-container | panic(main thread): Segmentation fault at address 0x0
js-container | oh no: Bun has crashed. This indicates a bug in Bun, not your code.
Relevant log output
Stack Trace (bun.report)
Bun v1.2.13 (64ed68c
) on linux x86_64_baseline [RunCommand]
Segmentation fault at address 0x00000000
WebSocket.h:275
:uws_ws_subscribe
uws.zig:0
:ServerWebSocketPrototype__subscribe
ZigGeneratedClasses.cpp:44415
:WebCore::ServerWebSocketPrototype__subscribeCallback
- 1 unknown/js code
ld-temp.o:0
:llint_op_call_ignore_result
ld-temp.o:0
:llint_call_javascript
Interpreter.cpp:1322
:JSC::Interpreter::executeCall
CallData.cpp:57
:Bun__JSValue__call
Features: tsconfig, tsconfig_paths, postgres_connections, Bun.stderr, Bun.stdin, Bun.stdout, dotenv, http_server, jsc