Skip to content

Commit 143cac1

Browse files
committed
Revert "No timeout expiration on node blocks exit"
This reverts commit f032369.
1 parent f032369 commit 143cac1

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/check/property/TimeoutProperty.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@ import { Shrinkable } from '../arbitrary/definition/Shrinkable';
33
import { IProperty } from './IProperty';
44

55
/** @hidden */
6-
const timeoutAfter = (timeMs: number) => {
7-
let timeoutHandle: (ReturnType<typeof setTimeout>) | null = null;
8-
const promise = new Promise<string>((resolve, reject) => {
9-
timeoutHandle = setTimeout(() => {
6+
const timeoutAfter = async (timeMs: number) =>
7+
new Promise<string>((resolve, reject) =>
8+
setTimeout(() => {
109
resolve(`Property timeout: exceeded limit of ${timeMs} milliseconds`);
11-
}, timeMs);
12-
});
13-
return { clear: () => clearTimeout(timeoutHandle!), promise };
14-
};
10+
}, timeMs)
11+
);
1512

1613
/** @hidden */
1714
export class TimeoutProperty<Ts> implements IProperty<Ts> {
@@ -21,9 +18,6 @@ export class TimeoutProperty<Ts> implements IProperty<Ts> {
2118
return this.property.generate(mrng, runId);
2219
}
2320
async run(v: Ts) {
24-
const t = timeoutAfter(this.timeMs);
25-
const propRun = Promise.race([this.property.run(v), t.promise]);
26-
propRun.then(t.clear, t.clear); // always clear timeout handle (equivalent to finally)
27-
return propRun;
21+
return Promise.race([this.property.run(v), timeoutAfter(this.timeMs)]);
2822
}
2923
}

0 commit comments

Comments
 (0)