Skip to content

Commit

Permalink
fix(flows): throw error when queueName contains colon (#2719) fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Aug 29, 2024
1 parent fea6b1a commit 9ef97c3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Empty file removed docs/gitbook/do-not-commit-.md
Empty file.
4 changes: 4 additions & 0 deletions docs/gitbook/guide/flows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
4 changes: 4 additions & 0 deletions src/classes/queue-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
12 changes: 12 additions & 0 deletions tests/test_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 9ef97c3

Please sign in to comment.