From d65866156d35f117597e31babde5413807230c18 Mon Sep 17 00:00:00 2001 From: Lucas Smith Date: Sat, 8 Nov 2025 13:57:26 +1100 Subject: [PATCH] fix: remove parallel steps (#2152) --- .../internal/seal-document.handler.ts | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/packages/lib/jobs/definitions/internal/seal-document.handler.ts b/packages/lib/jobs/definitions/internal/seal-document.handler.ts index 805855ecf..2180e1fd2 100644 --- a/packages/lib/jobs/definitions/internal/seal-document.handler.ts +++ b/packages/lib/jobs/definitions/internal/seal-document.handler.ts @@ -189,11 +189,44 @@ export const run = async ({ settings, }); - const decoratePromises: Array> = - []; + // !: The commented out code is our desired implementation but we're seemingly + // !: running into issues with inngest parallelism in production. + // !: Until this is resolved we will do this sequentially which is slower but + // !: will actually work. + // const decoratePromises: Array> = + // []; + + // for (const envelopeItem of envelopeItems) { + // const task = io.runTask(`decorate-${envelopeItem.id}`, async () => { + // const envelopeItemFields = envelope.envelopeItems.find( + // (item) => item.id === envelopeItem.id, + // )?.field; + + // if (!envelopeItemFields) { + // throw new Error(`Envelope item fields not found for envelope item ${envelopeItem.id}`); + // } + + // return decorateAndSignPdf({ + // envelope, + // envelopeItem, + // envelopeItemFields, + // isRejected, + // rejectionReason, + // certificateData, + // auditLogData, + // }); + // }); + + // decoratePromises.push(task); + // } + + // const newDocumentData = await Promise.all(decoratePromises); + + // TODO: Remove once parallelization is working + const newDocumentData: Array<{ oldDocumentDataId: string; newDocumentDataId: string }> = []; for (const envelopeItem of envelopeItems) { - const task = io.runTask(`decorate-${envelopeItem.id}`, async () => { + const result = await io.runTask(`decorate-${envelopeItem.id}`, async () => { const envelopeItemFields = envelope.envelopeItems.find( (item) => item.id === envelopeItem.id, )?.field; @@ -213,11 +246,9 @@ export const run = async ({ }); }); - decoratePromises.push(task); + newDocumentData.push(result); } - const newDocumentData = await Promise.all(decoratePromises); - const postHog = PostHogServerClient(); if (postHog) {