Skip to content

Commit

Permalink
Merge pull request Expensify#38923 from software-mansion-labs/ts/war-…
Browse files Browse the repository at this point in the history
…in/with-fail-timeout-hoc

[No QA] [TS migration] Migrate 'withFailTimeout.js' HOC to TypeScript
  • Loading branch information
yuwenmemon authored Mar 26, 2024
2 parents a0010c6 + 11c72ea commit e2cc1be
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import CONFIG from '../config';

const TIMEOUT = process.env.INTERACTION_TIMEOUT || CONFIG.INTERACTION_TIMEOUT;
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- nullish coalescing doesn't achieve the same result in this case
const TIMEOUT = Number(process.env.INTERACTION_TIMEOUT || CONFIG.INTERACTION_TIMEOUT);

const withFailTimeout = (promise, name) =>
const withFailTimeout = (promise: Promise<void>, name: string): Promise<void> =>
new Promise((resolve, reject) => {
const timeoutId = setTimeout(() => {
reject(new Error(`"${name}": Interaction timed out after ${(TIMEOUT / 1000).toFixed(0)}s`));
}, Number(TIMEOUT));
}, TIMEOUT);

promise
.then((value) => {
Expand Down

0 comments on commit e2cc1be

Please sign in to comment.