Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Starting two different subscriptions at the same time throws "an operation already exists with this id" #90

@osaxma

Description

@osaxma

Problem

In my app, I start two different subscriptions with two different queries at the start of the app (i.e., one listens for messages and one listens for notifications). Doing so for some reason throws the following error

{extensions: {path: $, code: start-failed}, message: an operation already exists with this id: "...... the id/key ...... " }

HasuraRequestError: an operation already exists with this id: "....... the id/key (same as above) ......"

A simple code to reproduce:

void main() async { 
  final url = '.....';
  final headers = {......};
  final query1 = 'subscription  messages { .......... }';
  final query2 = 'subscription  notifications { ......  }';

  final hasuraClient = HasuraConnect(url, headers: headers);

  (await hasuraClient.subscription(query1)).listen((event) {});
  (await hasuraClient.subscription(query2)).listen((event) {});
}

(In my app, I have them in separate places but they pretty much start at the same time)

a workaround:

adding some delay before one of the subscriptions makes solve the problem but it's not optimal (I found 300ms to be a good delay, anything lower will throw the error).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions