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

Race condition in both publisher and consumer getOrCreateChannel function #63

Open
apasare opened this issue Dec 11, 2024 · 1 comment · May be fixed by #64
Open

Race condition in both publisher and consumer getOrCreateChannel function #63

apasare opened this issue Dec 11, 2024 · 1 comment · May be fixed by #64

Comments

@apasare
Copy link

apasare commented Dec 11, 2024

The getOrCreateChannel function can create more than one channel per consumer/publisher. We noticed this bug in our consumers that have a prefetch of 30 and at some point try to notify others systems by doing pubsub.publish, the first time the daemon pod boots up this ends up creating as many channels as messages where prefetched at the same time. A small sample how to reproduce:

import amqp from 'amqplib';
import { AMQPPubSub } from 'graphql-amqp-subscriptions';

const pubsub = new AMQPPubSub('amqp://guest:guest@localhost:5672?heartbeat=30');

await Promise.all([
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
  pubsub.publish('test', { test: 'test' }),
]);
@cosmin-petrescu
Copy link

We notice this too and its reproducing a lot on large usage. Would be nice to have this released asap. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants