From 4b1a8e14c436c09828e5131aa1099de20e6f30d4 Mon Sep 17 00:00:00 2001 From: Owen Date: Wed, 20 May 2026 11:18:47 -0700 Subject: [PATCH] Put long running into the background to end transaction --- server/lib/rebuildClientAssociations.ts | 42 +++++++++++++++++++++---- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/server/lib/rebuildClientAssociations.ts b/server/lib/rebuildClientAssociations.ts index d881e8eeb..2c1e2b00a 100644 --- a/server/lib/rebuildClientAssociations.ts +++ b/server/lib/rebuildClientAssociations.ts @@ -600,9 +600,24 @@ async function handleMessagesForSiteClients( exitNodeJobs.push(updateClientSiteDestinations(client, trx)); } - await Promise.all(exitNodeJobs); - await Promise.all(newtJobs); // do the servers first to make sure they are ready? - await Promise.all(olmJobs); + Promise.all(exitNodeJobs).catch((error) => { + logger.error( + `rebuildClientAssociations: Error updating client site destinations for site ${site.siteId}:`, + error + ); + }); + Promise.all(newtJobs).catch((error) => { + logger.error( + `rebuildClientAssociations: Error updating Newt peers for site ${site.siteId}:`, + error + ); + }); + Promise.all(olmJobs).catch((error) => { + logger.error( + `rebuildClientAssociations: Error updating Olm peers for site ${site.siteId}:`, + error + ); + }); } interface PeerDestination { @@ -1245,9 +1260,24 @@ async function handleMessagesForClientSites( ); } - await Promise.all(exitNodeJobs); - await Promise.all(newtJobs); - await Promise.all(olmJobs); + Promise.all(exitNodeJobs).catch((error) => { + logger.error( + `rebuildClientAssociations: Error updating client site destinations for client ${client.clientId}:`, + error + ); + }); + Promise.all(newtJobs).catch((error) => { + logger.error( + `rebuildClientAssociations: Error updating Newt peers for client ${client.clientId}:`, + error + ); + }); + Promise.all(olmJobs).catch((error) => { + logger.error( + `rebuildClientAssociations: Error updating Olm peers for client ${client.clientId}:`, + error + ); + }); } async function handleMessagesForClientResources(