jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.39k stars 361 forks source link

AbortError: AbortError #166

Closed geoidesic closed 4 years ago

geoidesic commented 4 years ago

I'm getting an error like this:

Vue warn]: Error in v-on handler (Promise/async): "AbortError: AbortError"

No other information given. I'm simply trying db.instance.add("<storageName>", payload). The DB exists. How can I get more information about what's wrong?

piotr-cz commented 4 years ago

Same here, would be nice to get at least stack trace. For met his sometimes happens when payload overwrites existing entry (keyPath is present in store)

Source says Rejects if an item of a given key already exists in the store

Update: use put method

jakearchibald commented 4 years ago

I dunno if I'd expect that to be an abort error. I'm not sure what db.instance is either. Can either of you create a minimal reproduction of this issue?

piotr-cz commented 4 years ago

Error is thrown when you add an item with existing keyPath. So the fix is to use db.instance.put instad of db.instance.add.

Problem is that developer is left with plain AbortError which is not very informative and there is no stack trace attached.

jakearchibald commented 4 years ago

I'm not sure what db.instance is. It isn't part of the library. Can you create a minimal reproduction of this issue?

piotr-cz commented 4 years ago

When looking at https://github.com/jakearchibald/idb/issues/166#issue-587870262 it's a IDBDatabase object (result of openDB method).

jakearchibald commented 4 years ago

Can either of you create a minimal reproduction of this issue?

That way I can see the actual error you're seeing, and start debugging it.

chestozo commented 4 years ago

Hey guys I am also without a minimal reproduction case sorry. Just some details on my case.

I have a webapp installed on iPhone under iOS 13.3.1 (but I am seeing this error for half a year maybe). After I've switched to idb the error is just plain AbortError without any details and stacktrace. Before when I was working with indexedDB directly it was something like

Connection to Indexed Database server lost. Refresh the page to try again

I was investing it sometime ago and at that point I've switched to idb. One more detail: after I receive the first AbortError I try to reopen connection to database but it just stops working. Only full webapp restart helps.

Maybe it is related to this issue https://bugs.webkit.org/show_bug.cgi?id=197050

jakearchibald commented 4 years ago

Ok, it'd have been nice if someone had created a minimal reproduction, but I've gone ahead and created one myself https://static-misc-2.glitch.me/idb/add-error.html

If I've reproduced the same error you're seeing, it seems like I need to fix the shortcut methods so the rejection of the request takes priority over the transaction.

jakearchibald commented 4 years ago

I think the fix is as simple as https://github.com/jakearchibald/idb/commit/24e7d91cae412f4205a9cf8d5cfd9ab56fc7f311 - which means the error from the put/add/whatever takes priority over the error from the transaction. I need to write some tests for this before landing it.

Without a minimal reproduction from any of the reporters here, it's possible I'm tackling a completely different issue. If that's the case, please create a minimal reproduction of the issue you're seeing.

jakearchibald commented 4 years ago

Fixed in https://github.com/jakearchibald/idb/pull/181 and published as 5.0.3.

If this didn't solve the issue, please reopen, but I won't fix anything without a minimal reproduction of the issue.