-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(printer): increase timeout to 15s
- Loading branch information
1 parent
36b1930
commit 457aed5
Showing
6 changed files
with
28 additions
and
34 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
export const delay = (time: number) => new Promise((resolve) => setTimeout(resolve, time)); | ||
|
||
export const withTimeout = async <T>(promise: Promise<T>, time: number): Promise<T> => { | ||
const timeout = new Promise((_, reject) => | ||
setTimeout(() => { | ||
reject(new Error(`Operation timed out after ${time} ms.`)); | ||
}, time), | ||
); | ||
|
||
const timeout = new Promise((_, reject) => setTimeout(() => reject, time)); | ||
return Promise.race([promise, timeout]) as T; | ||
}; |