-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Describe the bug
When running multiple browser tests that involve click events on anchor elements, thousands of "Unknown event: response:response:response:..." errors occur. The response: prefix accumulates recursively, suggesting an infinite feedback loop in iframe communication.
Reproduction
External reproduction repo: simshanith/lit-ui-router#69
Steps:
- Clone https://github.com/simshanith/lit-ui-router
- Checkout commit
9d116d4 - Run
pnpm install - Run:
pnpm --filter lit-ui-router test ui-sref.spec -t "click modifiers" --browser=chromium
Expected behavior
Tests pass with no errors.
Actual behavior
Tests pass but with thousands of errors:
Error: Unknown event: response:response:response:response:response:execute
Error: Unknown event: response:response:response:response:response:cleanup
Analysis
Looking at packages/browser/src/client/tester/tester.ts lines 94-97:
channel.postMessage({
event: `response:${data.event}`,
iframeId: getBrowserState().iframeId!,
})When an unknown event arrives:
- It logs "Unknown event: {eventName}" via
unhandledError() - It still sends a response with
response:${data.event}
If responses somehow get echoed back (iframe routing issue with click events?), this creates a feedback loop:
execute→response:execute→response:response:execute→ ...
Hypothesis
Click events on anchors with target="_blank" or navigation-triggering attributes may cause iframe communication that echoes responses back to the handler.
Proposed Fix
Add a guard to prevent responding to events that already start with response::
// Before sending response, check if this is already a response event
if (data.event.startsWith('response:')) {
// Don't respond to response events - this would create infinite loop
return
}Key Details
- Issue only occurs when multiple tests run (individual tests pass)
- Tests involve click events on anchor elements
- Anchors may trigger navigation
- Some tests use
target="_blank"orrel="external"attributes - Error count grows exponentially with test count
Environment
- vitest: 4.0.16
- @vitest/browser-playwright: 4.0.16
- playwright: 1.54.1
- macOS
Metadata
Metadata
Assignees
Labels
Type
Projects
Status