Minor: remove any
s from createTaskWithTimeout
This commit is contained in:
parent
812b1c5b21
commit
b0b4c04c52
1 changed files with 5 additions and 5 deletions
|
@ -1,10 +1,10 @@
|
||||||
// tslint:disable no-default-export
|
// tslint:disable no-default-export
|
||||||
|
|
||||||
export default function createTaskWithTimeout(
|
export default function createTaskWithTimeout<T>(
|
||||||
task: () => Promise<any>,
|
task: () => Promise<T>,
|
||||||
id: string,
|
id: string,
|
||||||
options: { timeout?: number } = {}
|
options: { timeout?: number } = {}
|
||||||
) {
|
): () => Promise<T> {
|
||||||
const timeout = options.timeout || 1000 * 60 * 2; // two minutes
|
const timeout = options.timeout || 1000 * 60 * 2; // two minutes
|
||||||
|
|
||||||
const errorForStack = new Error('for stack');
|
const errorForStack = new Error('for stack');
|
||||||
|
@ -12,7 +12,7 @@ export default function createTaskWithTimeout(
|
||||||
return async () =>
|
return async () =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
let complete = false;
|
let complete = false;
|
||||||
let timer: any = setTimeout(() => {
|
let timer: NodeJS.Timeout | null = setTimeout(() => {
|
||||||
if (!complete) {
|
if (!complete) {
|
||||||
const message = `${id ||
|
const message = `${id ||
|
||||||
''} task did not complete in time. Calling stack: ${
|
''} task did not complete in time. Calling stack: ${
|
||||||
|
@ -43,7 +43,7 @@ export default function createTaskWithTimeout(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const success = (result: any) => {
|
const success = (result: T) => {
|
||||||
clearTimer();
|
clearTimer();
|
||||||
complete = true;
|
complete = true;
|
||||||
resolve(result);
|
resolve(result);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue