Created
October 9, 2023 13:58
-
-
Save tom-sherman/10079cf614d9aaf1dd857dbe13bfa101 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wrapWithSignal(ms, fn) { | |
const signal = AbortSignal.timeout(ms) | |
return fn(signal) | |
} | |
function foo() { | |
return wrapWithSignal(signal => fetch("/", {signal})) | |
} | |
try { | |
await foo() | |
} catch (e) { | |
console.error(e.message) | |
console.error(e.stack) | |
} | |
Result is: | |
VM2225:4 Failed to execute 'timeout' on 'AbortSignal': Value is not of type 'unsigned long long'. | |
(anonymous) @ VM2225:4 | |
VM2225:5 TypeError: Failed to execute 'timeout' on 'AbortSignal': Value is not of type 'unsigned long long'. | |
at wrapWithSignal (<anonymous>:2:32) | |
at foo (<anonymous>:2:12) | |
at <anonymous>:2:11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment