()
| 2615 | |
| 2616 | // Create a promise that rejects in <ms> milliseconds |
| 2617 | const timeout: () => Promise<T> = () => new Promise<T>((resolve, reject) => { |
| 2618 | timer = global.setTimeout(() => { |
| 2619 | clearTimeout(timer); |
| 2620 | if (cancelToken) { |
| 2621 | cancelToken.cancel(); |
| 2622 | } |
| 2623 | reject(localize("timed.out", "Timed out in {0}ms.", ms)); |
| 2624 | }, ms); |
| 2625 | }); |
| 2626 | |
| 2627 | // Returns a race between our timeout and the passed in promise |
| 2628 | return Promise.race([task(), timeout()]).then( |
no test coverage detected