Skip to content

config gloabl test timeout in bunfig.toml #7789

Open

Description

@xlc

What is the problem this feature would solve?

so that I don't need to set it for every single tests

What is the feature you are proposing to solve the problem?

have bunfig.toml supports gloabl timeout

For example, vitest supports config testTimeout in vitest.config.ts

What alternatives have you considered?

No response

Activity

  1. willhoney7 commented on Jan 23, 2026

    @willhoney7

    Ran into this today. Would be great to have timeout as an option in the bunfig.toml.

  2. kmarcisz commented on Jul 15, 2026

    @kmarcisz

    Same here, some of our tests are over 5s and we would like the per-test override be available in bunfig.

  3. removed their assignment
    on Aug 4, 2026
  4. code-yeongyu commented on Sep 4, 2026

    @code-yeongyu

    Reproduced on 1.4.0 (also 1.4.1), and adding a data point on why this matters more than a convenience.

    setDefaultTimeout is documented as file-scoped, and a preload only runs once per process — so a preload that calls it raises the budget for the first test file only; every later file in a sequential bun test run falls back to 5000ms. Minimal repro:

    mkdir -p repro/probe && cd repro
    printf '[test]\npreload = ["./setup.ts"]\n' > bunfig.toml
    printf 'import { setDefaultTimeout } from "bun:test"\nsetDefaultTimeout(20_000)\n' > setup.ts
    for n in a b c; do printf 'import { test, expect } from "bun:test"\ntest("%s", async () => { await new Promise((r) => setTimeout(r, 6500)); expect(true).toBe(true) })\n' $n > probe/$n.test.ts; done
    bun test probe            # 1 pass / 2 fail  (b,c: "timed out after 5000ms")
    bun test --parallel probe # 3 pass  (each worker re-runs the preload)
    bun test --timeout 20000 probe  # 3 pass
    

    The natural place to set a repo-wide default is [test] timeout in bunfig.toml — but as reported here it is silently ignored: with timeout = 20000 in [test] the run above is still 1 pass / 2 fail on 1.4.0. So today the only mechanism that reaches every file is the CLI flag, which has to be repeated at every bun test call site in CI.

    Real-world impact: a monorepo preload raising the CI floor to 30s on windows-latest silently protected one file per job; a 9.3s test died at 5000ms and was chased as a Windows flake for weeks. A parsed [test] timeout (or a documented note that a preload's setDefaultTimeout is first-file-only) would have made that a one-line fix.

  5. konard commented on Nov 14, 2026

    @konard

    Bounded reproduction on Bun 1.4.4, the current release on 2026-11-14: a single 6-second test with [test] timeout = 7000 still fails at 5000ms; the same test using file-local setDefaultTimeout(7000) passes in 6 seconds. Script: https://github.com/link-foundation/csharp-ai-driven-development-pipeline-template/blob/issue-108-555c331829cb/experiments/issue-82/reproduce-bun-timeout.mjs (two finite child runs, no stress allocation).

    Run bun experiments/issue-82/reproduce-bun-timeout.mjs. The first child demonstrates the ignored TOML setting and the second demonstrates the workaround. Our consumer keeps explicit file-local timeouts for subprocess integration tests; it does not skip tests or extend budgets to hide hangs: link-foundation/csharp-ai-driven-development-pipeline-template#109 .

    A parsed [test].timeout applied when initializing every test file would let consumers remove this duplicated setup. A regression should cover two sequential files so a preload affecting only the first file cannot appear to fix the setting. Adding current-version measured evidence to the existing report, with AI assistance.

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

    bun:testSomething related to the `bun test` runnerenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions