Skip to content

Commit 5ff7951

Browse files
committed
fix(run-engine): create message key when dequeuing V3 messages for execution
For V3 optimized format, we now create the message key when the run is dequeued from the worker queue (ready to execute). This allows ack/nack/readMessage to work correctly. Storage savings come from not having message keys while messages are PENDING in the queue backlog - only executing runs have message keys. https://claude.ai/code/session_01AyzQp6tbj7th5QRTCYjJR5
1 parent 7afe9ed commit 5ff7951

File tree

1 file changed

+6
-0
lines changed
  • internal-packages/run-engine/src/run-queue

1 file changed

+6
-0
lines changed

internal-packages/run-engine/src/run-queue/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,12 @@ export class RunQueue {
23732373
const descriptor = this.keys.descriptorFromQueue(decoded.queueKey);
23742374
const message = reconstructMessageFromWorkerEntry(decoded, descriptor);
23752375

2376+
// For V3 format: create the message key now that the run is executing.
2377+
// This allows ack/nack to work (they read from message key).
2378+
// Storage savings come from not having message keys for PENDING runs (the backlog).
2379+
const messageKey = this.keys.messageKey(descriptor.orgId, message.runId);
2380+
await this.redis.set(messageKey, JSON.stringify(message));
2381+
23762382
// Update the currentDequeued sets (this is done in the Lua script for legacy)
23772383
const queueCurrentDequeuedKey = this.keys.queueCurrentDequeuedKeyFromQueue(decoded.queueKey);
23782384
const envCurrentDequeuedKey = this.keys.envCurrentDequeuedKeyFromQueue(decoded.queueKey);

0 commit comments

Comments
 (0)