Skip to content

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

fix(api/nuq): bad mapping of property names when using rabbitmq

mogeryfe74e673c56b
diff --git a/apps/api/src/services/worker/nuq.ts b/apps/api/src/services/worker/nuq.ts
index eb4497bba..cf0cfceb0 100644
--- a/apps/api/src/services/worker/nuq.ts
+++ b/apps/api/src/services/worker/nuq.ts
@@ -478,6 +478,18 @@ class NuQ<JobData = any, JobReturnValue = any> {
};
}
+ // RabbitMQ payloads are already-mapped NuQJobs (camelCase) that have been
+ // serialized to JSON, so dates arrive as strings. Revive them here instead
+ // of running the payload back through rowToJob (which expects raw DB rows).
+ private rabbitRowToJob(row: any): NuQJob<JobData, JobReturnValue> | null {
+ if (!row) return null;
+ return {
+ ...row,
+ createdAt: new Date(row.createdAt),
+ finishedAt: row.finishedAt ? new Date(row.finishedAt) : undefined,
+ };
+ }
+
public async getJob(
id: string,
_logger = logger,
@@ -1293,7 +1305,7 @@ class NuQ<JobData = any, JobReturnValue = any> {
{ noAck: true },
);
if (job !== false) {
- return this.rowToJob(JSON.parse(job.content.toString()));
+ return this.rabbitRowToJob(JSON.parse(job.content.toString()));
} else {
return null;
}