Skip to content

[PR] fix: keep pre-reload imports out of the new egress module cache - #7042

Closed
Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-17_egress-module-generations
Closed

Afloat16 wants to merge 2 commits into
ranxianglei:masterfrom
Afloat16:2026-11-17_egress-module-generations

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

A plugin import started before POST /__bili/config/reload can finish after the reload and write into the freshly cleared module cache. It can silently restore old code for every later request, or replace a working new plugin with a cached import error. Clearing the map does not invalidate an in-flight import.

Change

Capture the module-cache generation when a load begins and only cache its outcome if that generation is still current. The request that started the old import may finish using its existing generation; subsequent requests keep the reloaded plugin.

Verification

  • Base: 301e1a5459a77d5578206927c8062a58381af642.
  • All three new regressions fail on the base: an old successful import replaces the new plugin, an old rejected import replaces it with a cached error, and a real HTTP request sees the old plugin after config reload.
  • The new and related egress suites pass 44 tests.
  • Tests use explicit top-level-await barriers and distinct module mtimes. The HTTP test edits the real plugin file, calls POST /__bili/config/reload, finishes the older request, and proves a subsequent request still runs the new plugin.
  • Full npm run typecheck, npm run build, and git diff --check: passed.
  • Codex preflight found the CLI and artifact but the configured upstream 127.0.0.1:8199 is unreachable; real four-phase host acceptance remains unrun.

Duplicate checks covered all states and Afloat16's history. #6649 implements per-route configuration reload; this fixes the separate asynchronous ESM module-cache publication race. There is no change to config schema, plugin ordering, transform timeouts or wire content.

Fixes #7041

@ranxianglei ranxianglei changed the title fix: keep pre-reload imports out of the new egress module cache [PR] fix: keep pre-reload imports out of the new egress module cache Nov 17, 2026
Merge upstream master 6a641f3, including the architecture module-map and schedule-independent ranxianglei#2929 probe fixes.

Preserve the existing PR head and exact contribution patch. Validation of this refreshed head runs in upstream CI; no local test rerun is claimed.
@ranxianglei

Copy link
Copy Markdown
Owner

This fix is included verbatim (original commits and authorship preserved) in the merged batch PR #7074 — the changes are already on master. Closing to avoid a duplicate merge. 该修复已随批量 PR #7074 原样合入 master,为避免重复合并,关闭此 PR。

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.

Pre-reload egress imports can overwrite a newly reloaded plugin

2 participants