Skip to content

Out of memory while copying request body #22514

Closed

Description

@Al-User12

How can we reproduce the crash?

panic(main thread): Out of memory while copying request body

Relevant log output

Bun v1.2.20 (6ad208bc) Windows x64
Windows v.win11_ga
CPU: sse42 avx avx2
Args: "C:\Users\AL FIKRI KM\.bun\bin\bun.exe" "run" "index.ts"
Features: Bun.stderr(2) Bun.stdin(2) Bun.stdout(2) fetch(43) jsc transpiler_cache tsconfig(2) tsconfig_paths
Builtins: "bun:main" "node:assert" "node:buffer" "node:child_process" "node:constants" "node:crypto" "node:events" "node:fs" "node:os" "node:path" "node:process" "node:readline" "node:stream" "node:tty" "node:util"
Elapsed: 565543ms | User: 21890ms | Sys: 12890ms
RSS: 0.46GB | Peak: 0.75GB | Commit: 15.96GB | Faults: 672101 | Machine: 8.44GB

Stack Trace (bun.report)

Bun v1.2.20 (6ad208b) on windows x86_64 [RunCommand]

panic: Out of memory while copying request body

Features: transpiler_cache, tsconfig, tsconfig_paths, Bun.stderr, Bun.stdin, Bun.stdout, fetch, jsc

Activity

  1. linear commented on Sep 9, 2025

    @linear
  2. github-actions commented on Sep 9, 2025

    @github-actions
    Contributor

    @Al-User12, thank you for reporting this crash. The latest version of Bun is v1.2.21, but this crash was reported on Bun v1.2.20.

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

    bun upgrade

    For Bun's internal tracking, this issue is BUN-VWQ.

  3. marked Crash #23927 as a duplicate of this issue on Oct 22, 2025
  4. added a commit that references this issue on Mar 18, 2026
    e737151
  5. robobun commented on May 13, 2026

    @robobun
    Collaborator

    This is the same missing receive-side backpressure as #28035 — a fetch() response body consumed via getReader() that stops pulling lets the HTTP client keep reading from the socket, and every chunk is appended unbounded into ByteStream.buffer until allocation fails at ByteStream.onData.

    Fix is in #29831, which pauses the socket (HTTP/1.1) / withholds flow-control credit (HTTP/2, HTTP/3) once the buffered bytes pass a high-water mark and resumes when the reader catches up.

  6. robobun commented on Jul 24, 2026

    @robobun
    Collaborator

    Fixed by #29831.

    Verified on main at df84f8d: a stalled fetch().body.getReader() now pauses the socket so ByteStream no longer buffers the entire response (the cause of the onData OOM panic); resume drains the full body.

    # 256 MiB body, read one chunk then stall
    main df84f8db1 : sent(stalled)=2.7 MiB   rssΔ=11 MiB    → full body received on resume
    bun 1.3.13     : sent(stalled)=256.0 MiB rssΔ=685 MiB  → unbounded buffering (OOM on larger bodies)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashAn issue that could cause a crashruntimeweb:fetchwindowsAn issue that is known to occur on Windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions