Skip to content

Commit

Permalink
Merge pull request #11 from swan-io/dead-spot-transaction
Browse files Browse the repository at this point in the history
Handle possible missed spot in timeout case
  • Loading branch information
bloodyowl authored Feb 15, 2024
2 parents 8953775 + 2d11863 commit 9ed55a7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/futurify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ export const futurify = <T>(
if (request.readyState !== "done") {
transaction.abort();
}
}).tapError((error) => resolve(Result.Error(error)));
})
.tapOk(() => {
resolve(
Result.Error(
createError(
"TimeoutError",
`${operationName} IndexedDB request timed out with status ${request.readyState}`,
),
),
);
})
.tapError((error) => resolve(Result.Error(error)));
}
}, timeout);

Expand Down

0 comments on commit 9ed55a7

Please sign in to comment.