Skip to content

bug(data): useSSE keeps using a stale parser after parse changes #3757

Description

@Tomeshwari-02

Summary

useSSE in packages/data/src/hooks/useSSE.ts accepts a parse callback, but the effect dependency list only includes [url]. If a component re-renders with the same URL and a new parser, incoming events are still parsed by the old callback.

Reproduction

  1. Render useSSE(url, parseA).
  2. Re-render the same component with the same url and parseB.
  3. Emit another message event from the same EventSource.

Expected behavior

The hook should use the latest parser, either by including parse in the dependency list or by storing the latest callback in a ref.

Actual behavior

The event listener closes over the parser from the original effect run, so future messages can be transformed incorrectly.

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