Skip to content

Shared DB test suites can't catch a test that finishes with server work in flight #762

Open

Description

@alecgibson

The shared DB suites pulled in by test/db.js (test/client/query-subscribe.js and friends) also run against real Mongo in CI's scripts/test-sharedb-mongo.sh step. In sharedb's own run, though, they use BasicQueryableMemoryDB, which calls back on process.nextTick and ignores closed after close(). So all server work has always finished before mocha's afterEach tears the backend down.

That means a test that calls done() while the server is still working passes here, and only fails in the sharedb-mongo step:

  1. A test calls done() on a side-effect event, such as a doc's 'op', while the server is still handling the request
  2. afterEach closes the backend, and with it the Mongo client
  3. The in-flight request errors with Operation interrupted because client was closed, and that error reaches done() a second time

#760 hit this with its "subscribed query results catch up on ops missed while disconnected" test, which finished on the missed op while the server was still re-polling the query.

Two possible fixes:

  • Make the memory DB that sharedb's own run uses defer its callbacks (setImmediate or setTimeout) and error once closed, so these tests fail locally too.
  • Or settle on a convention that shared-suite tests finish on the request's own reply or 'ready', never on a side-effect event, and rely on the sharedb-mongo step to enforce it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions