Skip to content

bug(data): useWebSocket keeps the previous message after URL changes #3759

Description

@Tomeshwari-02

Summary

useWebSocket in packages/data/src/hooks.ts reconnects when url changes, but it never clears the message state. Consumers can see the previous socket's last message while the new socket is still connecting.

Reproduction

  1. Render useWebSocket('wss://old.example').
  2. Receive a message such as old-data.
  3. Re-render with useWebSocket('wss://new.example').
  4. Inspect message before the new socket receives anything.

Expected behavior

A URL change should reset message to
ull or otherwise make it clear that the old message belongs to the old connection.

Actual behavior

The hook keeps returning the old message while state is already for the new connection lifecycle.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

assignedIssue claimed by a contributor.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions