Skip to content

[Bug] Repeated failures overwrite earlier incident dump files #7399

Description

@Afloat16

Description

The incident writers in src/error-dump.ts name files with only the current millisecond, sanitized session ID and HTTP status, then use an ordinary overwrite-capable write. Two rejected bodies or summary exchanges with the same name silently replace the earlier evidence.

These files are deliberately protected from retention GC because they capture high-value failure evidence. The name collision bypasses that protection at creation time.

Reproduction on the tested master:

  1. Enable the existing BILI_DUMP_4XX=1 option and use a temporary ACP_DUMP_DIR.
  2. Hold Date.now() at one timestamp to make the collision deterministic.
  3. Call dumpRejectedBody(400, "session", "first rejected body"), then call it again with "second rejected body".
  4. Both calls report the same path; reading the first returned path now yields the second body.
  5. dumpSummaryRejection() loses both sides of the first exchange the same way. Distinct raw session IDs that sanitize identically, or an existing incident left by another process, also collide.

Expected: each successful incident write returns its own path without replacing previous evidence. A real I/O failure should retain the existing fail-soft warning/null behavior.

bili version

0.1.216, tested master 1e357bf2d6632bfbd2a74ffb70ecee1af1ec7cc3.

Usage mode

Other / not sure: upstream rejection diagnostics and preflight summary failures; cross-client code.

Client and version

Node.js 24.22.3. The reproduction uses the actual incident writer and real files, with only the clock held fixed.

Operating system

Linux x86_64.

Upstream and model

No external provider or model is required. The fixture bodies contain synthetic text.

Configuration

The existing diagnostic dump option must be enabled. No new setting is proposed; dumps remain off by default.

Validation and suggested fix

The unchanged production has 7 failing file-preservation regressions and 1 passing I/O-error control. The prepared fix passes 30/30 targeted tests, including the existing banner, UTF-8 byte-cap and retention-GC suites unchanged.

Create files exclusively. Keep the historical filename when it is free; on a name collision, choose a UUID-suffixed path with a bounded descriptive session field and again use exclusive creation. Other errors remain fail-soft. This prevents replacement; it does not change fsync or partial-write semantics.

Typecheck, build, unused-export, test-import-graph and whitespace checks pass. All-author/all-state searches and the latest 100 open PRs found no equivalent change: #1994 separated main/summary prefixes; #4299 repaired byte limits; #4483 added the plaintext warning.

Triage

Priority: p1 (loss of retained incident evidence). Scope: scope/other. Topic: N (server miscellaneous). Cross-client code; no single host-lane label.

Prepared branch: Afloat16/billion-context@2026-11-20_preserve-colliding-error-dumps.

Activity

  1. Afloat16 commented on Nov 20, 2026

    @Afloat16
    ContributorAuthor

    (ai: OpenAI/GPT-6 Astra Pro)

    The fix is in PR #7400: #7400 . Both incident writers now create files exclusively, retaining the historical name when free and choosing a unique suffix only on collision. Earlier evidence is preserved. The unchanged base fails seven file-preservation regressions; the fix passes 30 focused tests, including the existing byte-cap/banner/GC coverage, plus typecheck/build and static gates. Full regression remains the remote CI lanes on the PR head.

    Triage: bug, p1, scope/other; Topic N. This is cross-client code, so no single host-lane label applies.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions