Skip to content

Fix dispatchEvent instrumentation regression and add reload regression benchmark#1468

Merged
KillariDev merged 8 commits into
mainfrom
t3code/7b679dc7
Jun 15, 2026
Merged

Fix dispatchEvent instrumentation regression and add reload regression benchmark#1468
KillariDev merged 8 commits into
mainfrom
t3code/7b679dc7

Conversation

@KillariDev

Copy link
Copy Markdown
Contributor

Summary

  • Switched inpage initialization to stop monkey-patching window.dispatchEvent; Interceptor now reinjects itself by listening for ethereum#initialized and dispatching the event after listener registration.
  • Added a regression benchmark for dispatchEvent reload behavior with three scenarios (current Interceptor, no extension, and simulated broken shim) via new benchmark page and server.
  • Extended Chrome benchmark harness to support reusable profiles through CHROME_USER_DATA_DIR / INTERCEPTOR_CHROME_PROFILE_DIR with optional cleanup behavior.
  • Added a benchmark npm script: bun run benchmark:dispatchevent-reload.
  • Updated inpage signer-bridge tests to verify window.dispatchEvent is restored and late ethereum#initialized reinjection keeps ethereum.isInterceptor semantics.

Testing

  • Not run: bun test.
  • Not run: bun run setup-chrome.
  • Not run: bun run typecheck.
  • Not run: bun run lint.
  • Not run: bun run benchmark:popup-lifecycle.
  • Not run: bun run benchmark:dispatchevent-reload.

- Keep `window.dispatchEvent` untouched by listening for `ethereum#initialized` reinjection events
- Add benchmark harness and repro page to compare Interceptor vs native vs broken dispatch behavior
- Extend Chrome session launcher to support persistent profiles via env vars
- Update inpage signer tests to verify dispatchEvent is restored and late wallet injection still reinjects
@KillariDev

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI Agent Review

No issues found across all agent reviews. The changes replace a window.dispatchEvent monkey-patch with a standard addEventListener/removeEventListener pattern, which all agents confirm is a correct and improved approach.

Remove removeEventListener from the onEthereumInitialized callback
so the listener stays active. The isInterceptor guard already prevents
unnecessary reinjections, making this safe. This also fixes the
late-reinjection test which expects the listener to still respond to
ethereum#initialized events dispatched after initial load.
@KillariDev

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CI Agent Review

No issues found across all review dimensions.

@KillariDev KillariDev requested a review from MicahZoltu June 15, 2026 09:44
@KillariDev KillariDev merged commit c3e2a09 into main Jun 15, 2026
1 check passed
@KillariDev KillariDev deleted the t3code/7b679dc7 branch June 15, 2026 10:17
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.

2 participants