Last active
March 23, 2022 00:37
-
-
Save lorensr/836c6f730ed7df66dd85d07966fe4d14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { poll } = proxyActivities<typeof activities>({ | |
startToCloseTimeout: '10m', | |
retryPolicy: { | |
initialInterval: '1h', | |
backoffCoefficient: 1 | |
} | |
}); | |
export const stopPolling = defineSignal('stopPolling'); | |
export async function resumeAfterCancellation(url: string): Promise<any> { | |
let result: any; | |
try { | |
result = await CancellationScope.cancellable(async () => { | |
setHandler(stopPolling, () => void CancellationScope.current().cancel()); | |
return await poll(url); | |
}); | |
} catch (err) { | |
if (!isCancellation(err)) { throw err } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can make this shorter: