Skip to content

Potential alias collision for subscriptions #2032

@vicary

Description

@vicary

When the exact same arguments are used across multiple subscriptions with different selections, GQty will generate the same query alias for them, leading to an incorrect cache update.

Consider the following case in React:

const sub1 = useSubscription();
sub1.foo({ bar: "baz" }).field1;

const sub2 = useSubscription();
sub2.foo({ bar: "baz" }).field2;

While sub1 and sub2 subscribes with a different ID in the WebSocket layer, they are stored to the cache under the same alias because of .foo({ bar: "baz" }), essentially gluing "next" message payloads for both sub1 and sub2.

The solution is to generate a unique alias for each subscription.


Thanks @jsjs_dev for reporting in Discord.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions