Skip to content

websocket crashing #20788

Open
Open
@0n8a7j5

Description

@0n8a7j5

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

Features: tsconfig, tsconfig_paths, postgres_connections, Bun.stderr, Bun.stdin, Bun.stdout, dotenv, http_server, jsc

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashAn issue that could cause a crashlinuxAn issue that occurs on Linuxold-versionUsing a very old version of Bunruntimeweb:websocket

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions