| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 736349c commit 0b1a9aa
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,14 +12,17 @@ const NS_PER_MS = 1000000n; | |||
| 12 | 12 | ||
| 13 | 13 | const hrtime = process.hrtime.bigint; | |
| 14 | 14 | ||
| 15 | + const loopDuration = common.platformTimeout(100n); | ||
| 16 | + const timeout = common.platformTimeout(10); | ||
| 17 | + | ||
| 15 | 18 | function loop() { | |
| 16 | 19 | const start = hrtime(); | |
| 17 | 20 | while (1) { | |
| 18 | 21 | const current = hrtime(); | |
| 19 | 22 | const span = (current - start) / NS_PER_MS; | |
| 20 | - if (span >= 100n) { | ||
| 23 | + if (span >= loopDuration) { | ||
| 21 | 24 | throw new Error( | |
| 22 | - `escaped timeout at ${span} milliseconds!`); | ||
| 25 | + `escaped ${timeout}ms timeout at ${span}ms`); | ||
| 23 | 26 | } | |
| 24 | 27 | } | |
| 25 | 28 | } | |
@@ -32,9 +35,9 @@ assert.throws(() => { | |||
| 32 | 35 | queueMicrotask, | |
| 33 | 36 | loop | |
| 34 | 37 | }, | |
| 35 | - { timeout: common.platformTimeout(5) } | ||
| 38 | + { timeout } | ||
| 36 | 39 | ); | |
| 37 | 40 | }, { | |
| 38 | 41 | code: 'ERR_SCRIPT_EXECUTION_TIMEOUT', | |
| 39 | - message: 'Script execution timed out after 5ms' | ||
| 42 | + message: `Script execution timed out after ${timeout}ms` | ||
| 40 | 43 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments