Skip to content

Commit

Permalink
Merge pull request #17 from swan-io/avoid-unhandled-promise
Browse files Browse the repository at this point in the history
Avoid having indexeddb.databases() call throw unhandled error
  • Loading branch information
bloodyowl authored Apr 18, 2024
2 parents e0c228a + 1a5ff49 commit c1a9f66
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ export const getFactory = (): Future<Result<IDBFactory, Error>> => {
remainingAttempts = remainingAttempts - 1;

if (remainingAttempts > 0) {
void indexedDB.databases().finally(() => {
const onResolve = () => {
clearInterval(intervalId);
resolve(Result.Ok(indexedDB));
});
};
void indexedDB.databases().then(onResolve, onResolve);
} else {
clearInterval(intervalId);

Expand Down

0 comments on commit c1a9f66

Please sign in to comment.