Skip to content

Commit

Permalink
fix: forward timeout waitForFileChooser
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Aug 29, 2022
1 parent e2d9858 commit 05e9550
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/common/Page.ts
Expand Up @@ -770,7 +770,8 @@ export class Page extends EventEmitter {

const {timeout = this.#timeoutSettings.timeout()} = options;
const promise = createDeferredPromiseWithTimer<FileChooser>(
`Waiting for \`FileChooser\` failed: ${timeout}ms exceeded`
`Waiting for \`FileChooser\` failed: ${timeout}ms exceeded`,
timeout
);
this.#fileChooserPromises.add(promise);
return promise.catch(error => {
Expand Down
11 changes: 7 additions & 4 deletions src/util/DeferredPromise.ts
Expand Up @@ -31,10 +31,13 @@ export function createDeferredPromiseWithTimer<T>(
resolver = resolve;
rejector = reject;
});
const timeoutId = setTimeout(() => {
isRejected = true;
rejector(new TimeoutError(timeoutMessage));
}, timeout);
const timeoutId =
timeout > 0
? setTimeout(() => {
isRejected = true;
rejector(new TimeoutError(timeoutMessage));
}, timeout)
: undefined;
return Object.assign(taskPromise, {
resolved: () => {
return isResolved;
Expand Down

0 comments on commit 05e9550

Please sign in to comment.