Skip to content
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

feat(ws): add logging to WebSocket connections #2112

Merged
merged 14 commits into from
Mar 30, 2024
Merged

Conversation

kettanaito
Copy link
Member

@kettanaito kettanaito commented Mar 27, 2024

WebSocket connections logging will only work in the browser (no request logs are printed in Node.js right now anyway).

Roadmap

  • Connection event
  • Outgoing client messages (actual .send())
  • Incoming client messages (actual "message" event)
  • Incoming (raw) server messages
  • Messages sent via server.send() (mocked outgoing client events)
  • Messages sent via client.send() (mocked incoming server events)
  • Error events
  • Close events
  • Respect the quiet: true option on the worker
  • Add unit tests for getMessageLength, getPublicData, and truncateMessage

@kettanaito
Copy link
Member Author

kettanaito commented Mar 27, 2024

Error: ReferenceError: crypto is not defined
 ❯ new WebSocketClientConnection node_modules/.pnpm/@mswjs+interceptors@0.26.13/node_modules/@mswjs/interceptors/src/interceptors/WebSocket/WebSocketClientConnection.ts:44:15
 ❯ src/core/ws/WebSocketClientManager.test.ts:33:22

Most likely the tests are loading the browser bundle of WebSocket interceptor (which refers to crypto as a global and doesn't have any shims). May be a testing setup issue on our end.

@kettanaito kettanaito changed the title feat(ws): log connections, outgoing events feat(ws): add logging to WebSocket connections Mar 29, 2024
@kettanaito kettanaito marked this pull request as ready for review March 30, 2024 09:15
@kettanaito kettanaito merged commit fc8b67d into feat/ws Mar 30, 2024
12 checks passed
@kettanaito kettanaito deleted the feat/ws-logging branch March 30, 2024 09:38
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.

None yet

1 participant