🎥 Make videos programmatically with React
`@remotion/renderer`: cleanup timeout in setPropsAndEnv() if the function throws
Jonny Burgerf581345c936e
diff --git a/packages/renderer/src/set-props-and-env.ts b/packages/renderer/src/set-props-and-env.tsindex bb167a0a91..e833a4dae6 100644--- a/packages/renderer/src/set-props-and-env.ts+++ b/packages/renderer/src/set-props-and-env.ts@@ -222,22 +222,24 @@ const innerSetPropsAndEnv = async ({export const setPropsAndEnv = async (params: SetPropsAndEnv) => {let timeout: NodeJS.Timeout | null = null;- const result = await Promise.race([- innerSetPropsAndEnv(params),- new Promise((_, reject) => {- timeout = setTimeout(() => {- reject(- new Error(- `Timed out after ${params.timeoutInMilliseconds} while setting up the headless browser. This could be because the you specified takes a long time to load (or network resources that it includes like fonts) or because the browser is not responding. Optimize the site or increase the browser timeout.`,- ),- );- }, params.timeoutInMilliseconds);- }),- ]);-- if (timeout !== null) {- clearTimeout(timeout);+ try {+ const result = await Promise.race([+ innerSetPropsAndEnv(params),+ new Promise((_, reject) => {+ timeout = setTimeout(() => {+ reject(+ new Error(+ `Timed out after ${params.timeoutInMilliseconds} while setting up the headless browser. This could be because the you specified takes a long time to load (or network resources that it includes like fonts) or because the browser is not responding. Optimize the site or increase the browser timeout.`,+ ),+ );+ }, params.timeoutInMilliseconds);+ }),+ ]);++ return result;+ } finally {+ if (timeout !== null) {+ clearTimeout(timeout);+ }}-- return result;};