apache / apache/pouchdb

New IndexedDB Adapter broken when used simultaneously on multiple browser pages

Open
#8,494 4 comments 3 reactions 0 assignees View on GitHub
stale
Dominant language
JavaScript
Stars
17.6k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

### Issue
If database updates are done to the same IndexedDB database through different browser pages, one will eventually break due to the metadata `seq` not being properly updated.

### Info
- Environment: Browser
- Platform: Chrome
- Adapter: indexeddb
- Server: Not required.

### Reproduce

On page load, create the Pouch Database:
```js
var db = new PouchDB('test', { adapter: 'indexeddb' });
```

On demand (using a button), create documents in the database
```js
await db.post({ title: 'Ziggy Stardust' });
```

1. Open the served pages on 2 different tabs
2. By alternating between pages, click on the button.

The following error will appear in the console: `Database has a global failure DOMException: Unable to add key to index 'seq': at least one key does not satisfy the uniqueness requirements.`
When looking at the IndexedDB state, `metadata.seq` is not updated between updates from other pages.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.