Skip to content

fix: missing 'server' in client-to-server forwarding example #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Zero-1016
Copy link

This PR fixes a missing server reference in the Client-to-server forwarding example. The original example does not define where server comes from, which may cause confusion. The fix updates the connection event handler to destructure both client and server properly.

Changes

Updated the event listener to include { client, server } instead of just { client }.

Before

chat.addEventListener('connection', ({ client }) => {
  client.addEventListener('message', (event) => {
    event.preventDefault()
    server.send(event.data + 'mocked')
  })
})

After

chat.addEventListener('connection', ({ client, server }) => {
  client.addEventListener('message', (event) => {
    event.preventDefault()
    server.send(event.data + 'mocked')
  })
})

Let me know if you want any adjustments! 🚀

Copy link

vercel bot commented Mar 15, 2025

@Zero-1016 is attempting to deploy a commit to the MSW Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant