Skip to content

Script automations that call bb spawn bb endlessly until the server runs out of memory #6435

Closed

Description

@ratulsarna

Summary

Every bb call from an automation script starts a new copy of itself, over and over, and never finishes. Each copy is a Node process of about 65 MB. The script hits its timeout, or the machine runs out of memory first. On my server the kernel OOM-killed bb.service twice within five minutes, which cut off every running thread. I expected the script's bb call to run the CLI once.

Versions and environment

  • Reproduced on [email protected] from npm (gitHead 7125b90a6f), and on a build of main at 0ba941bed4. runBundledCliCommand is unchanged on main at f8c0701e94.
  • Ubuntu 24.04, Linux 6.8. Node 22.23.4 in the repro; the service uses Node 24.22.1. Installed with npm i -g and run as a systemd user service.

Steps to reproduce

Minimal version, without an automation. It uses a throwaway data dir and a launcher shaped like the generated ~/.bb/bin/bb:

D=$(mktemp -d); npm install --prefix "$D" --no-audit --no-fund [email protected]
mkdir -p "$D/data/bin"
printf '#!/bin/sh\nexport BB_DATA_DIR="%s"\nexec "%s" "%s" "$@"\n' "$D/data" "$(command -v node)" "$D/node_modules/bb-app/dist/bb.js" > "$D/data/bin/bb"
chmod +x "$D/data/bin/bb"
"$D/data/bin/bb" --version                      # prints the version
BB_CLI="$D/data/bin/bb" setsid "$D/data/bin/bb" --version &
sleep 3; pgrep -fc "$D/node_modules/bb-app/dist/bb.js"
pkill -KILL -f "$D/node_modules/bb-app/dist/bb.js"

The trigger in the product: an installed bb (so BB_CLI_LAUNCHER is set) runs a script automation whose script calls "$BB_CLI" ....

Expected vs actual

Expected: the second command prints the version once.

Actual: no output, and 19 to 33 bb.js processes after 3 seconds over two runs, still growing. On the server:

2026-10-28T05:57:48+00:00 systemd[1419]: bb.service: Failed with result 'oom-kill'.
2026-10-28T05:57:48+00:00 systemd[1419]: bb.service: Consumed 1h 22min 58.040s CPU time, 26.4G memory peak, 0B memory swap peak.
2026-10-28T06:02:15+00:00 systemd[1419]: bb.service: Failed with result 'oom-kill'.

Evidence

What you ruled out

Suggested priority and effort

High: any script automation that calls bb can take down the server, and running threads are lost when it does. The workaround is to pause those automations. Effort is low; I'll send a PR.

Found in bb thread thr_smfiqpe3ik and investigated in thr_h7xjtip5xk.

AGENT GENERATED

Activity

  1. added theissue type on Oct 28, 2026
  2. added
    host
    cli
    automations
    confirmed-repro
    on Oct 28, 2026
  3. bb-slop-cop commented on Oct 28, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority High · Effort Low. Labels: host, cli, automations, confirmed-repro.
    • Report: Reproduction and root-cause evidence — REPRODUCED, confidence high.
    • Root cause: The bb-app CLI entry follows BB_CLI without honoring the existing re-exec guard. When the override points back to its launcher, each child repeats the same delegation.
    • Verification: Two clean trusted-main checkouts reproduced four bounded launcher entries with no output; the control printed the version once. A newly authored regression fails on unchanged production code. Memory exhaustion was deliberately not induced.
    • No duplicate PR: Open #6436 already links this issue and proposes the guard fix; its code was reviewed statically, not executed. No additional fix was pushed.

    AGENT GENERATED

  4. pascal-de-ladurantaye commented on Oct 29, 2026

    @pascal-de-ladurantaye
    Contributor

    Still affects the desktop 0.48.0 release on macOS, because the fix doesn't ship in it: #6436 merged as 544e49c1fe at 2026-10-28T19:07Z, and desktop-v0.48.0 was cut at 17:17Z. compare/desktop-v0.48.0...544e49c1fe shows the fix 11 commits ahead and 0 behind.

    What I observed (macOS, bb desktop 0.48.0, /Applications/bb.app):

    • A script automation ran "${BB_CLI:-bb}" machine list --all --json once, with BB_CLI=~/.bb/bin/bb and BB_CLI_LAUNCHER=~/.bb/bin/bb in its environment.
    • The chain went wake.sh → bb.js machine list → bb.js machine list → …, each process the parent of the next. There were 835 processes after about 1m40s and 890 a few seconds later, about 47 GB RSS in total (sum of ps -o rss). I stopped it with pkill -KILL.
    • Workaround until the next desktop release: unset BB_CLI at the top of automation scripts.

    Not reproduced again on purpose; this is what I saw live. Filed by mistake as #6557, which I'm closing as a duplicate of this.

    AGENT GENERATED

  5. Geczy commented on Oct 29, 2026

    @Geczy

    Need this fix asap, how can I get on the nightly build?

  6. added a commit that references this issue on Oct 30, 2026
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

    automationscliconfirmed-reprohost

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions