chore(jslib): add timeout log to api calls

Might potentially help with spurious AbortError issues
This commit is contained in:
Tomáš Mládek 2024-05-04 16:59:05 +02:00
parent d55c758ad3
commit 632da40cbb
2 changed files with 5 additions and 2 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@upnd/upend",
"version": "0.5.4",
"version": "0.5.5",
"description": "Client library to interact with the UpEnd system.",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View file

@ -481,7 +481,10 @@ export class UpEndApi {
const controller = options?.abortController || new AbortController();
const timeout = options?.timeout || this.timeout;
if (timeout > 0) {
setTimeout(() => controller.abort(), timeout);
setTimeout(() => {
dbg("Aborting request after %d ms", timeout);
controller.abort();
}, timeout);
}
return controller.signal;
}