fix(concurrency): json serialization issues, ttls, feature flag redirection#3847
fix(concurrency): json serialization issues, ttls, feature flag redirection#3847icecrasher321 wants to merge 9 commits intostagingfrom
Conversation
PR SummaryMedium Risk Overview BullMQ/dispatch retention and claim semantics are tightened. BullMQ job Fixes serialization/cleanup edge cases. Written by Cursor Bugbot for commit d34d6f4. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR fixes several production issues in the worker-based (BullMQ) execution system: JSON serialization failures from Lua-side CJSON mutations, stale TTLs consuming Redis memory, and incorrect feature-flag routing that prevented BullMQ from being used when it should have been. Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant API as API Route
participant PW as Webhook Processor
participant BQ as isBullMQEnabled()
participant LUA as Redis Lua Script
participant RS as RedisStore (TypeScript)
participant RDB as Redis
Note over API,RDB: Workflow / Schedule / Webhook Execution (BullMQ path)
API->>BQ: isBullMQEnabled()?
BQ-->>API: Boolean(env.REDIS_URL)
alt BullMQ enabled
API->>RDB: enqueueWorkspaceDispatch(...)
RDB-->>API: jobId
else Inline fallback
API->>API: getJobQueue() → inline execution
end
Note over LUA,RDB: Redis Dispatch Claim (new non-atomic flow)
LUA->>RDB: ZADD leaseKey (atomic)
LUA->>RDB: ZREM laneKey (atomic)
LUA-->>RS: { type: admitted, jobId }
RS->>RDB: GET jobKey(jobId)
RDB-->>RS: record (status: pending)
alt Record found
RS->>RDB: SET jobKey(jobId) {status: admitting, lease: ...}
RS-->>API: AdmittedResult + updatedRecord
else Record missing / expired
RS-->>API: throw Error (job already removed from lane — lost!)
end
Note over API,RDB: Job Completion / Failure
API->>RDB: SET jobKey {status: completed, bullmqPayload: undefined}
API->>RDB: DECR global-depth
|
|
bugbot run |
|
bugbot run |
Summary
Fixes multiple issues surfaced from prod deployment of worker based execution system.
Type of Change
Testing
To be tested in Dev Sandbox
Checklist