Skip to content

app tests: three append-only process-global caches leak across tests (experiments layers, telemetry queue, bootstrap cache) #13974

Closed

Description

@fbartho

Summary

Three tests pass in isolation but fail in full-suite runs because each depends on a process-global cache that some other test populates with real (non-test) data and never resets. They share one root-cause pattern — an append-only or first-writer-wins global that has no per-test teardown — so they are grouped here. These currently report as failures on every contributor's full-suite PR gate.

Affected tests

  • experiments::tests::test_create_experiment_layer_mappings — app/src/experiments/mod_tests.rs:152
  • server::telemetry::tests::test_persist_events_doesnt_include_ugc_events — app/src/server/telemetry/mod_tests.rs:46
  • terminal::bootstrap::tests::test_trims_whitespace — app/src/terminal/bootstrap_tests.rs:46

Reproduction

Full suite (fails; these three appear among the 12-14 failures):

cargo test -p warp --lib

Each passes in isolation:

cargo test -p warp --lib -- --exact experiments::tests::test_create_experiment_layer_mappings
cargo test -p warp --lib -- --exact server::telemetry::tests::test_persist_events_doesnt_include_ugc_events
cargo test -p warp --lib -- --exact terminal::bootstrap::tests::test_trims_whitespace
# => each: ok. 1 passed

--test-threads=1 does not fix them: these are cumulative process-global caches carried across sequential tests, not data races. A full single-threaded run still fails with the same set.

Root cause

1. experiments — EXPERIMENT_LAYER_MAPPINGS never cleared

// app/src/experiments/mod.rs:77
static ref EXPERIMENT_LAYER_MAPPINGS: DashMap<&'static str, &'static Layer> = DashMap::new();

create_experiment_layer_mappings only inserts, never clears the map. The public experiments::init maps the four real layers into this same global. Any test that runs app.update(experiments::init) — e.g. workspace/view_tests.rs:229, pane_group/mod_tests.rs:202, terminal/input_tests.rs:314, and the shared helper test_util/terminal.rs:186 — leaves the real layers behind. test_create_experiment_layer_mappings then asserts EXPERIMENT_LAYER_MAPPINGS.len() == 2 (mod_tests.rs:152) and sees more than 2. In isolation the map only holds the 2 test experiments.

2. telemetry — global TELEMETRY event queue drained wholesale

// crates/warpui_core/src/telemetry/mod.rs:13
static ref TELEMETRY: Mutex<EventStore> = Mutex::new(EventStore::new());

EventStore.events is a 1024-cap BoundedVecDeque. record_event / create_event push onto this shared queue with no auto-flush, so any prior test that emits telemetry (e.g. ExperimentTriggered, emitted from experiments::mod.rs:337) leaves events queued. test_persist_events_doesnt_include_ugc_events records 2 events then calls flush_and_persist_events_at_path(max=10, ...), which drains the entire global queue and persists the last 10 non-UGC events, so assert_eq!(file_content.len(), 1) (mod_tests.rs:46) sees more than 1. The run log line "More telemetry events in queue than the limit to persist" is that exact overflow branch firing when the queue is already polluted past 10.

3. bootstrap — BOOTSTRAP_CACHE keyed on ShellType only, ignoring the asset provider

// app/src/terminal/bootstrap.rs:23
static ref BOOTSTRAP_CACHE: MemoMap<ShellType, Vec<u8>> = Default::default();

script_for_shell memoizes on ShellType alone; the AssetProvider argument is not part of the cache key:

// app/src/terminal/bootstrap.rs:129
BOOTSTRAP_CACHE.get_or_insert(&shell_type, || {
    let file_path = format!("bundled/bootstrap/{file}");
    ...
})

First writer for a given ShellType wins for the rest of the process. Production PtyController::initialize_shell calls script_for_shell(shell_type, &crate::ASSETS) (pty_controller.rs:381), so any terminal/session test that drives a Zsh shell to ready populates BOOTSTRAP_CACHE[Zsh] with the real bundled zsh.sh. test_trims_whitespace (bootstrap_tests.rs:46) passes a TestAssetProvider but gets the cached real-asset script instead, so its exact-string assertion fails. In isolation it is the sole Zsh writer and sees its own fixture. (Sibling bootstrap tests use Bash/Fish/PowerShell keys, so they do not collide with each other — only a real-ASSETS Zsh writer breaks this one.)

Fix direction

  • experiments: clear EXPERIMENT_LAYER_MAPPINGS at the start of the test (or have create_experiment_layer_mappings replace rather than append), and #[serial] it so a concurrent experiments::init cannot repopulate mid-test.
  • telemetry: drain the shared queue at the top of the test — warpui::telemetry::clear_event_queue() already exists (crates/warpui_core/src/telemetry/mod.rs:47) — and mark the test #[serial].
  • bootstrap: include the asset-provider identity in the BOOTSTRAP_CACHE key, or expose a test-only cache reset / bypass. #[serial] alone will not help here because the pollution is cumulative first-writer-wins, not concurrent.

Related

Related: #13853 (warp_editor render::tests Once-poisoning — same class, different crate) and the sibling flake tickets filed alongside this one: #13972, #13973, #13975

Activity

  1. warp-for-oss commented on Jul 19, 2026

    @warp-for-oss
    Contributor

    @fbartho

    Here's what I found while triaging this issue:

    The report includes concrete full-suite and isolated-test reproduction commands, and code inspection supports the shared-process-state failure mode. No reporter follow-up is needed for initial routing.

    Maintainer details

    I concluded that full-suite app tests appear to fail because several process-global caches or queues persist state across test cases while the affected tests assume isolated state..

    Triage summary

    This looks like a reproducible test-suite bug rather than a user-environment issue. The report provides exact failing full-suite and passing isolated-test commands, and the current code supports the shared process-global state explanation.

    Observed/code-supported findings:

    • app/src/experiments/mod.rs defines EXPERIMENT_LAYER_MAPPINGS as a process-global DashMap, and create_experiment_layer_mappings inserts entries without clearing or replacing unrelated previous entries. app/src/experiments/mod_tests.rs then asserts an exact map length of 2 after inserting the test layer.
    • crates/warpui_core/src/telemetry/mod.rs stores telemetry events in a process-global TELEMETRY queue. app/src/server/telemetry/mod_tests.rs records two events and then app/src/server/telemetry/mod.rs flushes the entire global queue before filtering/persisting, so earlier queued events can affect the assertion.
    • app/src/terminal/bootstrap.rs memoizes script_for_shell results in BOOTSTRAP_CACHE by ShellType only. Production shell initialization in app/src/terminal/writeable_pty/pty_controller.rs calls it with real assets, while app/src/terminal/bootstrap_tests.rs calls it with TestAssetProvider; whichever Zsh script is cached first wins for later calls in the same process.

    I did not find enough duplicate evidence to mark this as a duplicate. Open issues #13972, #13973, and #13975 look related as sibling full-suite/global-state flakes, but they cover different globals and affected tests rather than the same failure.

    No reporter follow-up is needed for initial routing; the remaining work is implementation/validation of isolated test state or cache-key/reset behavior.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Powered by Oz

  2. added
    bug
    repro:high
    triaged
    on Jul 19, 2026
  3. szgupta commented on Jul 20, 2026

    @szgupta
    Member

    @oz-agent can you repro this issue? Our CI uses cargo nextest - is it possible that is behaving differently than vanilla cargo test?

  4. warp-for-oss commented on Jul 20, 2026

    @warp-for-oss
    Contributor

    @szgupta

    I could not run a live repro in this sandbox because cargo is not installed here, so this is based on code inspection plus nextest behavior.

    Yes — cargo nextest is expected to behave differently from cargo test -p warp --lib for this report. Nextest runs each test in a separate process by default, while vanilla libtest runs many warp lib tests in one test-binary process; these three failures depend on process-global state being populated by earlier tests in that same process.

    So the issue still looks valid for shared-process cargo test, but CI that only uses cargo nextest run is likely to mask this exact class of leak. If CI is seeing these failures, I would first check whether another CI step still invokes vanilla cargo test or whether the failing log is from a non-nextest runner.

    Reasoning

    Code inspection supports the reporter's shared-process root-cause pattern. In app/src/experiments/mod.rs, EXPERIMENT_LAYER_MAPPINGS is a lazy static DashMap (mod.rs:77) and create_experiment_layer_mappings only inserts into it (mod.rs:384-390); app/src/experiments/mod_tests.rs:148-152 then asserts the global map length is exactly 2, which is order-dependent if experiments::init already populated real layers.

    Telemetry also uses process-global state: crates/warpui_core/src/telemetry/mod.rs:13 defines static TELEMETRY, record_event appends to its EventStore (mod.rs:75-90), and flush_events drains it (mod.rs:106-108). app/src/server/telemetry/mod_tests.rs:8-46 records two events and expects only one persisted non-UGC event, but app/src/server/telemetry/mod.rs:161-181 drains the entire global queue before filtering/persisting. There is an app-level clear_event_queue helper at app/src/server/telemetry/mod.rs:37-43, but this test does not call it before recording.

    Bootstrap has the first-writer-wins cache described in the issue: app/src/terminal/bootstrap.rs:23 defines BOOTSTRAP_CACHE: MemoMap<ShellType, Vec<u8>>, and script_for_shell keys get_or_insert only by ShellType (bootstrap.rs:129) even though the generated script depends on the AssetProvider. app/src/terminal/bootstrap_tests.rs:47 expects Zsh output from TestAssetProvider, so any earlier same-process Zsh bootstrap using real assets can poison that assertion.

    For the maintainer's nextest question: .config/nextest.toml only configures timeouts, integration-test thread weight, CI output, JUnit, and some retries; it does not configure these unit tests into a shared process. The cargo-nextest docs state that the default execution model is process-per-test and expose NEXTEST_EXECUTION_MODE=process-per-test, so these append-only/first-writer-wins globals should reset between individual tests under nextest. I attempted cargo nextest --version, but the sandbox returned bash: cargo: command not found, so I could not verify by executing the suite here.

    Duplicate scan: fetched all open repository issues via gh api --paginate, excluding PRs and #13974, plus recently closed issues updated since 2026-07-13. Related sibling app-test flake issues found included #13972, #13973, #13975, #13979, #13980, and recently closed #13853, but they cover different globals/tests or same-class failures rather than this exact three-cache issue. Fewer than two likely duplicates were identified.

    This is my automated analysis and may be incorrect. A maintainer will verify the details.

    Powered by Oz

  5. fbartho commented on Jul 20, 2026

    @fbartho
    ContributorAuthor

    @szgupta I root caused some of these flakes, and in some cases they were examples of code that wasn't using the must_use drop-guards. (Due to a weirdness in how cargo merges things with the integration crate, the must_use wasn't presenting an issue to the developers)

    So I'm in progress of spinning up some PRs to clean up the clearly incorrectly written test-cases (the vast majority of call-sites do the right thing).
    (I'm also switching to using cargo nextest in my local environment which would have hidden these flakes for me personally).

  6. fbartho commented on Jul 21, 2026

    @fbartho
    ContributorAuthor

    I proactively attempted an implementation based on the ticket as it's currently written: #14041.

    If the ticket changes, I'm happy to update the PR to match a maintainer's guidance, just let me know!

  7. fbartho commented on Jul 28, 2026

    @fbartho
    ContributorAuthor

    Just nudging @oss-maintainers that this is still a real flake, and that I have a proposed fix here: #14041

  8. szgupta commented on Jul 29, 2026

    @szgupta
    Member

    @fbartho sorry for the delay - we will be looking at this today (cc @acarl005)

  9. added
    ready-to-implement
    on Jul 29, 2026
  10. warp-for-oss commented on Jul 29, 2026

    @warp-for-oss
    Contributor

    This issue has been labeled ready-to-implement and is open for contributions involving code changes. If you'd like to tackle it, feel free to open a pull request against this issue. You can also comment @oz-agent on this issue to have the bot draft an implementation PR automatically.

  11. warp-agent-staging commented on Jul 29, 2026

    @warp-agent-staging
    Contributor

    Your GitHub account is not connected to Warp. Connect it here.

  12. warp-agent-staging commented on Jul 29, 2026

    @warp-agent-staging
    Contributor

    Picked this up via a factory automation (issue assigned) and started the factory loop.

    Noted that #14041 is already open for this issue (currently CHANGES_REQUESTED), so the loop is pointed at that PR rather than opening a second one. I'll report back here when triage finishes.

  13. warp-agent-staging commented on Jul 29, 2026

    @warp-agent-staging
    Contributor

    Routing complete — triage dispatched.

    GitHub issue_assigned on https://github.com/warpdotdev/warp/issues/13974|warpdotdev/warp#13974 (real engineering issue, not an automation wiring test). No factory gate label existed, so it routes to triage — the default loop entry.

    • Ticket: https://linear.app/warpdotdev/issue/APP-5044/app-tests-three-append-only-process-global-caches-leak-across-tests|APP-5044 (Eng-App FA, In Progress, related to the CSAT-10195 GHUR mirror)
    • Triage run: <https://oz.staging.warp.dev/runs/019faea2-8b39-7eb0-8df1-34b2ad702731|Oz run>
    • Posted back on the issue: https://github.com/warpdotdev/warp/issues/13974#issuecomment-5120430825|comment

    Flagged as critical context: <https://github.com/warpdotdev/warp/pull/14041|PR #14041> is already open for this issue (human-authored, CHANGES_REQUESTED), so downstream must continue on that PR rather than open a duplicate.

    Waiting for triage to report.

  14. warp-agent-staging commented on Jul 29, 2026

    @warp-agent-staging
    Contributor

    Triage complete.

    • Ticket: APP-5044 — status Todo, estimate S (2), gate label triage-done
    • Repo confirmed: warpdotdev/warp (single repo)
    • Triage run: Oz run

    Root cause confirmed on master by code inspection for all three globals (EXPERIMENT_LAYER_MAPPINGS, the TELEMETRY queue, and BOOTSTRAP_CACHE). Triage's conclusion: the remaining work is finishing and landing #14041, not new greenfield work — that PR already implements clear+#[serial] for experiments/telemetry and the (ShellType, TypeId) bootstrap cache key.

    No spec recommended, so this auto-advances straight to implementation, scoped to continuing on #14041 (branch fb/13974-global-cache-test-isolation). No second PR will be opened.

  15. warp-agent-staging commented on Jul 29, 2026

    @warp-agent-staging
    Contributor

    Implementation dispatched, scoped to continuing #14041 — Oz run.

  16. warp-agent-staging commented on Jul 29, 2026

    @warp-agent-staging
    Contributor

    Triage complete → implementation dispatched (auto-advance).

    • Ticket https://linear.app/warpdotdev/issue/APP-5044/app-tests-three-append-only-process-global-caches-leak-across-tests|APP-5044 — status Todo, estimate S (2), label triage-done, repo warpdotdev/warp
    • spec_recommended: false → no spec gate; straight to implementation
    • Triage run: <https://oz.staging.warp.dev/runs/019faea2-8b39-7eb0-8df1-34b2ad702731|Oz run>
    • Implementation run: <https://oz.staging.warp.dev/runs/019faeb1-d57d-7b6d-acfd-660694bfe1ac|Oz run>

    Triage's key finding: the remaining work is finishing and landing the already-open <https://github.com/warpdotdev/warp/pull/14041|PR #14041>, not greenfield work. The implementation child is scoped to that branch (fb/13974-global-cache-test-isolation) and explicitly told not to open a second PR.

  17. warp-agent-staging commented on Jul 29, 2026

    @warp-agent-staging
    Contributor

    Factory loop started for https://github.com/warpdotdev/warp/issues/13974|warpdotdev/warp#13974 (GitHub issue_assigned automation).

    What I did
    • Confirmed this was a real engineering request, not a factory-automation-verify wiring test.
    • Found no factory gate label on the issue, so routed it to triage — the default loop entry. Searched Linear first: only the Customer Support GHUR mirror CSAT-10195 existed, so I created the factory ticket https://linear.app/warpdotdev/issue/APP-5044/app-tests-three-append-only-process-global-caches-leak-across-tests|APP-5044 in Eng-App FA and linked it as related to CSAT-10195 rather than clobbering the support mirror.
    • Dispatched triage (https://oz.staging.warp.dev/runs/019faea2-8b39-7eb0-8df1-34b2ad702731|run). It came back: status Todo, estimate S (2), label triage-done, repo confirmed warpdotdev/warp, spec_recommended: false.
    • spec_recommended: false means no spec gate, so I auto-advanced straight to implementation (https://oz.staging.warp.dev/runs/019faeb1-d57d-7b6d-acfd-660694bfe1ac|run) after running the mandatory pre-dispatch PR check.

    The key finding
    There is already an open, human-authored PR for this issue — https://github.com/warpdotdev/warp/pull/14041|#14041 by fbartho on branch fb/13974-global-cache-test-isolation, currently CHANGES_REQUESTED. Triage confirmed the remaining work is finishing and landing that PR, not greenfield implementation. I scoped the implementation child to that branch and explicitly forbade opening a second PR; I verified no duplicate PR was created.

    Where it stands
    Implementation is still running — the warp crate's Rust build is heavy and triage already hit an OOM on a full cargo test -p warp in this runner class. My bounded wait (3 polls) expired with no completion: no factory PR mapping yet, PR #14041 still at head b70f042 with 3 commits, ticket still triage-done/Todo.

    Reply continue to resume the loop — I'll pick up from the ticket's gate label and auto-dispatch code review once impl-done lands. Step results are posted on the GitHub issue (https://github.com/warpdotdev/warp/issues/13974#issuecomment-5120430825|routing, <https://github.com/warpdotdev/warp/issues/13974#issuecomment-5120588400|triage result>, <https://github.com/warpdotdev/warp/issues/13974#issuecomment-5120616359|impl dispatch>) and on APP-5044.

  18. acarl005 commented on Aug 13, 2026

    @acarl005
    Contributor

    Closing as only cargo nextest is supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugready-to-implementrepro:hightriagedwarp:auto-triage-review

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions