brett
04/26/2021, 6:30 PMvans163
04/26/2021, 6:31 PMvans163
04/26/2021, 6:32 PMvans163
04/26/2021, 6:32 PMvans163
04/26/2021, 6:32 PMbrett
04/26/2021, 6:34 PMvans163
04/26/2021, 6:35 PMbrett
04/26/2021, 6:36 PMongoingUpdates[jobId]
for a promise, if there is one, wait for it to settle, then put your own promise in there.vans163
04/26/2021, 6:36 PMvans163
04/26/2021, 6:37 PMvans163
04/26/2021, 6:39 PMvans163
04/26/2021, 6:39 PM{
error: "crash",
stack_trace: "Error: Transaction failed due to conflict while processing a put() operation."
}
vans163
04/26/2021, 6:39 PMvans163
04/26/2021, 6:40 PMvans163
04/26/2021, 6:41 PMvans163
04/26/2021, 6:44 PMbrett
04/26/2021, 6:46 PMwhile (true) {
let ongoingJob = this.ongoingJobs[jobId];
if (typeof ongoingJob === undefined) {
let promise = asyncFunctionThatDoesProcessing().then(() => {
// Success, remove ourselves from the ongoingJobs object.
delete this.ongoingJobs[jobId];
}, (err) => {
// Error, remove ourselves from the ongoingJobs object.
delete this.ongoingJobs[jobId];
// Report the error somewhere, or throw if you want other requests to see it.
});
// Store the promise so other requests see it and await.
ongoingJob[jobId] = promise;
// Await our own work.
await promise;
// Break out of the loop, we're done.
break;
} else {
// Wait for someone else's work to complete.
await ongoingJob;
// Loop back around.
}
}
brett
04/26/2021, 6:46 PMbrett
04/26/2021, 6:50 PMbrett
04/26/2021, 6:50 PMUnsmart | Tech debt
04/27/2021, 1:57 AMkenton
04/27/2021, 2:03 AMUnsmart | Tech debt
04/27/2021, 2:04 AMkenton
04/27/2021, 2:05 AMkenton
04/27/2021, 2:06 AMUnsmart | Tech debt
04/27/2021, 2:07 AMvans163
04/27/2021, 2:37 AMvans163
04/27/2021, 2:37 AMvans163
04/27/2021, 2:39 AM{"error":"Durable Object exceeded its CPU time limit and was reset.","stack_trace":"Error: Durable Object exceeded its CPU time limit and was reset."}
Unsmart | Tech debt
04/27/2021, 2:39 AM