-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(package): resolve hanging retry connection timeout by introducing…
… cancelable timeout
- Loading branch information
1 parent
6b512e8
commit e37dd1a
Showing
2 changed files
with
27 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
export function wait(timeInMs) { | ||
return new Promise(function(resolve) { | ||
return setTimeout(resolve, timeInMs); | ||
let timeoutHandle; | ||
|
||
const promise = () => { | ||
return new Promise(function (resolve) { | ||
timeoutHandle = setTimeout(resolve, timeInMs); | ||
return timeoutHandle; | ||
}); | ||
} | ||
}; | ||
|
||
return { promise, cancel: () => clearTimeout(timeoutHandle) }; | ||
} |