From 9ef97c37663e209f03c501a357b6b1a662b24d99 Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Thu, 29 Aug 2024 07:10:41 -0600 Subject: [PATCH] fix(flows): throw error when queueName contains colon (#2719) fixes #2718 --- docs/gitbook/do-not-commit-.md | 0 docs/gitbook/guide/flows/README.md | 4 ++++ src/classes/queue-base.ts | 4 ++++ tests/test_queue.ts | 12 ++++++++++++ 4 files changed, 20 insertions(+) delete mode 100644 docs/gitbook/do-not-commit-.md diff --git a/docs/gitbook/do-not-commit-.md b/docs/gitbook/do-not-commit-.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docs/gitbook/guide/flows/README.md b/docs/gitbook/guide/flows/README.md index ac86388745..b101f51f43 100644 --- a/docs/gitbook/guide/flows/README.md +++ b/docs/gitbook/guide/flows/README.md @@ -77,6 +77,10 @@ The above call will return instances for all the jobs added to the queue. Note that the parent queue does not need to be the same queue as the one used for the children. {% endhint %} +{% hint style="warning" %} +If a jobId option is provided, make that it does not contain a colon **:** as this is considered a separator. +{% endhint %} + When the parent job is processed it is possible to access the results generated by its child jobs. For example, lets assume the following worker for the child jobs: {% tabs %} diff --git a/src/classes/queue-base.ts b/src/classes/queue-base.ts index a22cf424ac..41097e966d 100644 --- a/src/classes/queue-base.ts +++ b/src/classes/queue-base.ts @@ -53,6 +53,10 @@ export class QueueBase extends EventEmitter implements MinimalQueue { throw new Error('Queue name must be provided'); } + if (name.includes(':')) { + throw new Error('Queue name cannot contain :'); + } + this.connection = new Connection( opts.connection, isRedisInstance(opts.connection), diff --git a/tests/test_queue.ts b/tests/test_queue.ts index 39cc448e6d..75cff55d5d 100644 --- a/tests/test_queue.ts +++ b/tests/test_queue.ts @@ -46,6 +46,18 @@ describe('queues', function () { }); }); + describe('when empty name contains :', () => { + it('throws an error', function () { + expect( + () => + new Queue('name:test', { + connection, + prefix, + }), + ).to.throw('Queue name cannot contain :'); + }); + }); + describe('when empty name is provided', () => { it('throws an error', function () { expect(