Skip to content

Conversation

@simshanith
Copy link

Description

Resolves #9379

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.

  • guard against response: prefix events even before main switch

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

return
}

if (data.event.startsWith('response:')) {
Copy link
Member

Choose a reason for hiding this comment

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

It should not receive this even here at all, this doesn't fix the issue, it hides it

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the review @sheremet-va - agreed this is a symptom and not the root cause.

investigating further and adding test case. will share plan

Copy link
Author

Choose a reason for hiding this comment

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

I still don't know exactly how iframes of two or more tests end up communicating, potentially an iframeId collison.

I've simulated the behavior with a second broadcast channel that echos with the response: prefix unguarded. Additionally added the guard around postMessage. With the browser package from main, the test exhibits the infinite loop that crashed my computer a few times. With the guards, it passes without error.

Avoid infinite response event loop by only sending
response messages for events that were successfully handled.

Changes:
- Add eventHandled flag to track successful event processing
- Only call channel.postMessage for handled events
- Add reproduction test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@netlify
Copy link

netlify bot commented Jan 4, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit da0e8c0
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/695afe174fad260008901f89
😎 Deploy Preview https://deploy-preview-9381--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

Browser mode: Infinite 'Unknown event: response:response:...' loop when running multiple click tests

2 participants