Skip to content

Bun process does not exit after Tinypool destroy() completes (worker threads remain alive) #29173

Closed

Description

@kevgeoleo

What version of Bun is running?

1.3.11-canary.1+9e93bfa1b

What platform is your computer?

Linux 5.10.0-12-amd64 x86_64 x86_64

What steps can reproduce the bug?

Hi,

I would like to report a behavior in Bun that can be reproduced using the below PoC:

  1. worker.mjs
export default ({ a, b }) => a + b;
  1. foo.mjs
import Tinypool from "tinypool";

const pool = new Tinypool({
  filename: new URL("./worker.mjs", import.meta.url).href,
});

const result = await pool.run({ a: 4, b: 6 });
console.log(result); // Expected: 10

await pool.destroy();
  1. package.json
{
  "name": "node-bun-tinypool-poc",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "tinypool": "0.8.3"
  }
}
  1. npm install
  2. bun run foo.mjs

What is the expected behavior?

Print 10 and exit

root@KContainer:~/23263# node foo.mjs
10

What do you see instead?

Prints 10 and does not finish execution

root@KContainer:~/23263# bun run foo.mjs
10
^C

Additional information

No response

Activity

  1. github-actions commented on Apr 11, 2026

    @github-actions
    Contributor

    Found 3 possible duplicate issues:

    1. Worker.terminate() in Bun behaviorally different from Node #29077
    2. node:worker_threads Worker#terminate promise does not keep event loop alive #12614
    3. node:worker_threads Worker#terminate does not terminate infinite loops #12616

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. robobun commented on Apr 11, 2026

    @robobun
    Collaborator

    ✅ Reproduced — worker.terminate() hangs because the worker is parked in Atomics.wait (tinypool's atomicsWaitLoop). Fix in #29179 — from the parent thread we set hasTerminationRequest on the child VM and notify its syncWaiter condition directly, so the wait loop exits and atomicsWaitImpl returns Terminated.

    Core tinypool repro now exits cleanly; PR is pending a couple of residual test crashes in unrelated worker teardown paths that surface the termination-flag interaction.

  3. added a commit that references this issue on Apr 11, 2026
    d74e9a1
  4. added a commit that references this issue on Jul 21, 2026
    4e4d839
  5. added a commit that references this issue on Aug 8, 2026
    9d519e8
  6. added a commit that references this issue on Aug 8, 2026
    85f6c4c
  7. robobun commented on Aug 14, 2026

    @robobun
    Collaborator

    For anyone landing here: this was closed by #37075, but builds from that change alone still hung on this report's root cause (worker.terminate() against a worker parked in Atomics.wait(), which is where Tinypool's idle workers sit). The part that fixes that landed in #38457 (merge commit 97a4363, via a WebKit bump), so the first build containing that commit is the one to test against. Verified with the bare Atomics.wait() repro against main at that commit, not with Tinypool itself.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions