diff options
Diffstat (limited to 'language-web/src/main/js/editor/PendingRequest.ts')
-rw-r--r-- | language-web/src/main/js/editor/PendingRequest.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/language-web/src/main/js/editor/PendingRequest.ts b/language-web/src/main/js/editor/PendingRequest.ts index 784f06ec..49d4c36c 100644 --- a/language-web/src/main/js/editor/PendingRequest.ts +++ b/language-web/src/main/js/editor/PendingRequest.ts | |||
@@ -9,16 +9,24 @@ export class PendingRequest { | |||
9 | 9 | ||
10 | private readonly rejectCallback: (reason?: unknown) => void; | 10 | private readonly rejectCallback: (reason?: unknown) => void; |
11 | 11 | ||
12 | private readonly timeoutCallback: () => void; | ||
13 | |||
12 | private resolved = false; | 14 | private resolved = false; |
13 | 15 | ||
14 | private timeoutId: NodeJS.Timeout; | 16 | private timeoutId: NodeJS.Timeout; |
15 | 17 | ||
16 | constructor(resolve: (value: unknown) => void, reject: (reason?: unknown) => void) { | 18 | constructor( |
19 | resolve: (value: unknown) => void, | ||
20 | reject: (reason?: unknown) => void, | ||
21 | timeout: () => void, | ||
22 | ) { | ||
17 | this.resolveCallback = resolve; | 23 | this.resolveCallback = resolve; |
18 | this.rejectCallback = reject; | 24 | this.rejectCallback = reject; |
25 | this.timeoutCallback = timeout; | ||
19 | this.timeoutId = setTimeout(() => { | 26 | this.timeoutId = setTimeout(() => { |
20 | if (!this.resolved) { | 27 | if (!this.resolved) { |
21 | this.reject(new Error('Request timed out')); | 28 | this.reject(new Error('Request timed out')); |
29 | this.timeoutCallback(); | ||
22 | } | 30 | } |
23 | }, REQUEST_TIMEOUT_MS); | 31 | }, REQUEST_TIMEOUT_MS); |
24 | } | 32 | } |