Skip to content

[PR] fix: discard header edits from failed egress plugins - #6608

Merged
ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_egress-header-isolation
Nov 14, 2026
Merged

ranxianglei merged 1 commit into
ranxianglei:masterfrom
Afloat16:2026-11-13_egress-header-isolation

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Fixes #6607

Problem

An egress plugin can change the live request headers and then throw, time out or return an invalid body. The runner skips its result but leaves those partial edits in the request and in the next plugin's input. A timed-out plugin can also resume later and change headers after the pipeline has returned.

A real HTTP regression uses an actual local ESM plugin that overwrites the test credential and then throws. On unchanged master, the upstream behind startServer receives the rejected placeholder credential and the client gets 401. With this change, the original working credential is preserved and the same request returns 200.

Change

Give each matching plugin a private writable header draft. Commit successful direct edits back into the original live map before merging the returned header patch. Discard drafts on throw, timeout or invalid body, so late writes from a timed-out task stay isolated.

Successful direct mutation remains supported, including undefined/null returns and deletion of fields. The caller retains the original header-map object. Only header state is isolated; Buffer/body handling, plugin-task cancellation, timeout duration, ordering, signing and configuration are unchanged. Unconfigured and unmatched plugins remain no-ops.

Validation

  • New suite on unchanged master: 5 failures, 3 passing controls.
  • Applying [PR] fix: replace egress plugin headers case-insensitively #6606 alone leaves the same 5 failures and 3 controls: all credential keys here have identical lowercase spelling.
  • Independent fix: 32 tests pass across egress-header-isolation, egress-transforms and issue5688-egress-wiring.
  • Temporarily composing this fix with [PR] fix: replace egress plugin headers case-insensitively #6606: 41 tests pass, including both new suites and both existing suites.
  • Coverage includes throw/timeout/invalid-body failure, subsequent-plugin input, a deterministically released late task, successful undefined/null direct mutation, combined direct/returned edits, preserved live-map identity and the real HTTP outcome.
  • npm run typecheck, npm run build, npm run check:unused-exports, npm run check:test-import-graph and git diff --check pass.

Baseline: e1f31ad9d5b47500362699a9867819b861c7de96 (0.1.213); Node v24.22.1; repository test/storage preloads. Full-suite validation remains with hosted CI on this head.

Prior work

All-state egress/mutate/timeout/rollback searches and contributor history found no existing isolation fix. #6068 introduced the pipeline; its failure cases do not modify headers. #6606 fixes returned-header name replacement. This PR keeps that merge loop intact and addresses a different failure boundary.

Suggested triage: bug, p2, scope/wiring; Topic N — server-side miscellaneous.

@ranxianglei ranxianglei changed the title fix: discard header edits from failed egress plugins [PR] fix: discard header edits from failed egress plugins Nov 13, 2026
@ranxianglei
ranxianglei merged commit 3fdd2a8 into ranxianglei:master Nov 14, 2026
44 of 48 checks passed
@ranxianglei

Copy link
Copy Markdown
Owner

Superseded by #6677 (merged as 3858b6956, 2026-11-14).

Landed into master via the real merge commit 3fdd2a85644 (Merge Afloat16/2026-11-13_egress-header-isolation (PR #6608)), so your original commits are preserved verbatim in master history — only hashes of the batch wrapper changed, your authorship and commit messages are intact.

The fix for #6607 is now in master. Closing this PR as superseded — thanks for the careful, well-tested fix.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed or timed-out egress plugins still change outgoing request headers

2 participants