Skip to content

Commit 2511cb8

Browse files
authored
feat: add jitter for github nango onboarding (#3630)
1 parent edc4b45 commit 2511cb8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

services/apps/nango_worker/src/workflows/syncGithubIntegration.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { proxyActivities } from '@temporalio/workflow'
1+
import { proxyActivities, sleep } from '@temporalio/workflow'
22

33
import * as activities from '../activities/nangoActivities'
44
import { ISyncGithubIntegrationArguments } from '../types'
55

66
const activity = proxyActivities<typeof activities>({
7-
startToCloseTimeout: '10 minutes',
7+
startToCloseTimeout: '1 hour',
88
})
99

1010
export async function syncGithubIntegration(args: ISyncGithubIntegrationArguments): Promise<void> {
@@ -59,6 +59,12 @@ export async function syncGithubIntegration(args: ISyncGithubIntegrationArgument
5959
await activity.startNangoSync(result.providerConfigKey, connectionId)
6060

6161
created++
62+
63+
if (created < limit) {
64+
// random delay between 1-5 minutes to not overload nango server
65+
const jitterMs = 60000 + Math.random() * 240000
66+
await sleep(jitterMs)
67+
}
6268
}
6369
}
6470
}

0 commit comments

Comments
 (0)