Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(nuq): per-instance listen channel ID (#2336)

Gergő Móricze190165273a3
diff --git a/apps/api/audit-ci.jsonc b/apps/api/audit-ci.jsonc
index 8c59c3718..ec4744025 100644
--- a/apps/api/audit-ci.jsonc
+++ b/apps/api/audit-ci.jsonc
@@ -7,6 +7,7 @@
"GHSA-qj3p-xc97-xw74|@coinbase/x402>x402>wagmi>@wagmi/connectors>@metamask/sdk", // we don't use the Metamask SDK in the browser
"GHSA-qj3p-xc97-xw74|@coinbase/x402>x402>wagmi>@wagmi/connectors>@metamask/sdk>@metamask/sdk-communication-layer", // we don't use the Metamask SDK in the browser
"GHSA-ffrw-9mx8-89p8|@coinbase/x402>x402>wagmi>@wagmi/connectors>@walletconnect/ethereum-provider>@reown/appkit>@reown/appkit-utils>@walletconnect/logger>pino>fast-redact", // unused
- "GHSA-m732-5p4w-x69g|@coinbase/x402>x402>wagmi>@wagmi/connectors>porto>hono" // we don't use hono
+ "GHSA-m732-5p4w-x69g|@coinbase/x402>x402>wagmi>@wagmi/connectors>porto>hono", // we don't use hono
+ "GHSA-q7jf-gf43-6x6p|@coinbase/x402>x402>wagmi>@wagmi/connectors>porto>hono" // we don't use hono
]
}
diff --git a/apps/api/src/services/worker/nuq.ts b/apps/api/src/services/worker/nuq.ts
index 2d85481f0..30b876eb0 100644
--- a/apps/api/src/services/worker/nuq.ts
+++ b/apps/api/src/services/worker/nuq.ts
@@ -59,12 +59,12 @@ function normalizeOwnerId(ownerId: string | undefined | null): string | null {
return uuidv5(ownerId, normalizedUUIDNamespace);
}
-const listenChannelId =
- (process.env.NUQ_POD_NAME ?? "main") + "-" + crypto.randomUUID();
-
// === Queue
class NuQ<JobData = any, JobReturnValue = any> {
+ private listenChannelId: string =
+ (process.env.NUQ_POD_NAME ?? "main") + "-" + crypto.randomUUID();
+
constructor(
public readonly queueName: string,
public readonly options: NuQOptions,
@@ -97,7 +97,7 @@ class NuQ<JobData = any, JobReturnValue = any> {
const channel = await connection.createChannel();
await channel.prefetch(1);
const queue = await channel.assertQueue(
- this.queueName + ".listen." + listenChannelId,
+ this.queueName + ".listen." + this.listenChannelId,
{
exclusive: true,
autoDelete: true,
@@ -663,7 +663,7 @@ class NuQ<JobData = any, JobReturnValue = any> {
id,
data,
options.priority ?? 0,
- options.listenable ? listenChannelId : null,
+ options.listenable ? this.listenChannelId : null,
normalizeOwnerId(options.ownerId),
options.groupId ?? null,
...(options.backlogged
@@ -781,7 +781,7 @@ class NuQ<JobData = any, JobReturnValue = any> {
job.id,
job.data,
job.options.priority ?? 0,
- job.options.listenable ? listenChannelId : null,
+ job.options.listenable ? this.listenChannelId : null,
normalizeOwnerId(job.options.ownerId),
job.options.groupId ?? null,
...(tableSuffix === "_backlog"