Skip to content

Keep the E2E state file bridge out of production extension builds - #19147

Draft
Adam Ratzman (adamint) wants to merge 1 commit into
microsoft:mainfrom
adamint:adamint/e2e-bridge-production-gate
Draft

Keep the E2E state file bridge out of production extension builds#19147
Adam Ratzman (adamint) wants to merge 1 commit into
microsoft:mainfrom
adamint:adamint/e2e-bridge-production-gate

Conversation

@adamint

Copy link
Copy Markdown
Member

Description

extension/src/testing/e2eStateFileBridge.ts is a test control channel. It registers a wildcard debug adapter tracker factory and executes commands read from a file whose path comes from an environment variable. extension.ts imports it unconditionally and webpack.config.js had no build-time gate, so the entire channel was bundled into the published VSIX and gated only at runtime by ASPIRE_EXTENSION_E2E_ENABLE_BRIDGE.

This replaces the bridge with a no-op stub in production builds using NormalModuleReplacementPlugin, so the code is not present in the shipped bundle at all.

vscode:prepublish runs webpack --mode production and vsce package runs vscode:prepublish, so every packaging path gets the stub. yarn compile (mode none) and yarn watch keep the real bridge, so local development and the E2E runner are unaffected.

NormalModuleReplacementPlugin is used rather than DefinePlugin plus dead code elimination because dropping the module through tree shaking would require adding a sideEffects declaration to package.json.

Validation

Verified with three real webpack builds, counting bridge-only symbols in the emitted dist/extension.js:

build proveMauiResourceDebugging stoppingPathEvents atomicWriteSequence
stock config, --mode production 1 1 present
gated config, yarn package 0 0 0
gated config, yarn compile 3 6 2

getResourceDebugProofRequest and clipboardExpectation are also 0 in the gated production bundle.

From extension/:

yarn run compile-tests   Done in 2.96s
yarn run lint            Done in 3.68s
yarn run unit-test       1458 passing, 4 pending, 0 failing

The new unit test was negative-tested in both directions: breaking the replacement pattern and removing an export from the stub each produced a failing assertion naming the specific problem.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • No. This removes an unnecessary surface rather than adding one, so no new assumption is introduced.

Copilot AI balanced review requested due to automatic review settings August 7, 2026 18:13
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19147

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19147"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents the E2E control bridge from shipping in production VS Code extension bundles.

Changes:

  • Replaces the bridge with a production-only no-op module.
  • Preserves the real bridge for development and E2E builds.
  • Adds focused configuration and export compatibility tests.
Show a summary per file
File Description
extension/webpack.config.js Adds production module replacement.
extension/src/testing/e2eStateFileBridge.production.ts Provides the no-op production implementation.
extension/src/test/e2eBridgeProductionGate.test.ts Tests build-mode gating and stub compatibility.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@adamint
Adam Ratzman (adamint) marked this pull request as draft August 7, 2026 18:16
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

`src/testing/e2eStateFileBridge.ts` is a test control channel: it registers a
wildcard debug adapter tracker and executes commands read from a file path
supplied in an environment variable. `extension.ts` imports it unconditionally
and `webpack.config.js` had no build-time gate, so the whole channel was bundled
into the published VSIX and gated only at runtime by
`ASPIRE_EXTENSION_E2E_ENABLE_BRIDGE`.

Swap the bridge for a no-op stub via `NormalModuleReplacementPlugin` when
webpack runs in production mode. `vscode:prepublish` runs `webpack --mode
production`, and `vsce package` runs `vscode:prepublish`, so every shipping path
gets the stub. `yarn compile` (mode `none`) and `yarn watch` keep the real
bridge, so the E2E runner is unaffected.

`NormalModuleReplacementPlugin` is used rather than `DefinePlugin` plus dead code
elimination because dropping the module through tree shaking would require a
`sideEffects` declaration in `package.json`.

Verified by three real webpack builds, counting bridge-only symbols in
`dist/extension.js`:

  stock config, production:  proveMauiResourceDebugging=1, stoppingPathEvents=1
  gated config, production:  proveMauiResourceDebugging=0, stoppingPathEvents=0,
                             getResourceDebugProofRequest=0,
                             clipboardExpectation=0, atomicWriteSequence=0
  gated config, `yarn compile`: proveMauiResourceDebugging=3,
                             stoppingPathEvents=6, atomicWriteSequence=2

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@adamint
Adam Ratzman (adamint) force-pushed the adamint/e2e-bridge-production-gate branch from e93e41a to 045f313 Compare August 7, 2026 20:15
Copilot AI review requested due to automatic review settings August 7, 2026 20:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants