Skip to content

Conversation

@pubkey
Copy link
Owner

@pubkey pubkey commented Apr 15, 2022

This PR contains:

Describe the problem you have without this PR

Todos

  • Tests
  • Documentation
  • Typings
  • Changelog

@PaulMest
Copy link
Contributor

PaulMest commented Apr 27, 2022

Failing test:

it('pouchdb.find() should not return design-docs', async () => {
  ...
}

More information

When the failing test is run in isolation, it passes.

it.only('pouchdb.find() should not return design-docs', async () => {
  ...
  // I pass
}

However, when the failing test is run alongside 1 specific other test, it fails:

it.only('must be able to insert->update->delete via new_edits:false', async () => {
  ...
  // I pass
}

it.only('pouchdb.find() should not return design-docs', async () => {
  ...
  // I fail
}

If you put in a small delay, both tests pass:

it.only('must be able to insert->update->delete via new_edits:false', async () => {
  ...
  // I pass
}

it.only('pouchdb.find() should not return design-docs', async () => {
  // add in a small delay, so there is no overlap of creating this database and closing the other test's database
  await promiseWait(50);
  ...
  // Now I pass, too
}

Preventing closing one in-memory database when another in-memory database is open also allows the test to pass

it.only('must be able to insert->update->delete via new_edits:false', async () => {
  ...
  // Don't close pouch on this test
  // pouch.close();
  // I pass
}

it.only('pouchdb.find() should not return design-docs', async () => {
  ...
  // Now I pass, too
}

If I add debug logging to pouch-db-integration.test.ts

const pouchdbDebug = require('pouchdb-debug');
PouchDB.plugin(pouchdbDebug);
PouchDB.debug.enable('pouchdb:*');

... it seems like the closing a database in the passing test causes the failing test database to stop responding.

  pouchdb:api my-failing-test-mrview-e45c095c4e756d5f91187a3809e62305 bulkDocs { docs: [ { _id: '_local/lastSeq', seq: 1 } ] } +1ms
  pouchdb:api foobar23-my-passing-test get success {
  value: 5,
  _id: 'foobar23',
  _rev: '1-14af8c9a835820969a8a273b18783a70'
} +0ms
  pouchdb:api foobar23-my-passing-test close +0ms
  pouchdb:api foobar23-my-passing-test close success undefined +0ms
    ✔ must be able to insert->update->delete via new_edits:false
    1) pouchdb.find() should not return design-docs

My best guess is that there was a change to the pouchdb-memory-adapter in 7.3.0 and it does not properly isolate databases (closing one in-memory database impacts another in-memory database).

@pubkey
Copy link
Owner Author

pubkey commented May 24, 2022

Fixed in #3807

@pubkey pubkey closed this May 24, 2022
@pubkey pubkey deleted the feature/pouchdb-7-3-0 branch January 18, 2023 23:33
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

Successfully merging this pull request may close these issues.

3 participants