Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeleteDB should call Close() #309

Open
wparad opened this issue Apr 11, 2024 · 5 comments
Open

DeleteDB should call Close() #309

wparad opened this issue Apr 11, 2024 · 5 comments

Comments

@wparad
Copy link

wparad commented Apr 11, 2024

DeleteDB always gets blocked because the database is never closed. It should automatically be closed on Delete.

Otherwise something like this is necessary:

unwrap(await db).close();
await new Promise(resolve => setTimeout(resolve, 10000));

const deleteAsync = deleteDB(databaseName, {
    blocked(blockedVersion, blockedEvent) {
          logger.error({ title: 'Database blocked from being deleted', blockedVersion, blockedEvent });
    }
}
@retorquere
Copy link

Why not just db.close()?

@retorquere
Copy link

and why the wait? db is not intrinsically a promise, right? If you do const db = await openDB(...), db is a IDBP, not a Promise for an IDBP.

@retorquere
Copy link

This works for me:

const db = openDB(.., {
  blocked: () => db.close()
})

...

deleteDB(db)

@wparad
Copy link
Author

wparad commented Sep 4, 2024

I don't believe the types supported that. But I can always check again.

And close is async, and I believe blocked doesn't handle promises well. But something might have changed.

@retorquere
Copy link

So how should I ascertain I can delete the database?

Is close async? Close on plain indexeddb doesn't have event handlers right? If so, why would it be async in this library?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants