Skip to content

Silent failure when % symbol in document #2651

@bradrydzewski

Description

@bradrydzewski

The below example silently fails and does not complete the promise. It seems to happen when I try to query and emit a document that has a % sign. If I remove the % sign everything works.

I've tested using both the leveldb and the idb adapters using PouchDB version 2.2.3 and 3.0.1. I was wondering if anyone else could reproduce with the below code:

var PouchDB = require('pouchdb');

var db = new PouchDB('testdb', { db: require('memdown') });

describe('PouchDB', function() {

    it('should insert a document', function (done) {
        db.put({_id: "123-456-789", message: "I 100% agree" })
            .then(function(result){
                expect(result.ok).toBe(true);
                expect(result.id).toBe("123-456-789");
                done();
            })
            .catch(function(err){
                console.log(err)
                expect(err).toBeUndefined();
                done();
            });
    });

    it('should retrieve a list of documents', function (done) {

        function map(doc, emit) {
            emit(doc);
        }

        db.query({ map: map, reduce: false})
            .then(function(result){
                expect(result.total_rows).toBe(1);
                expect(result.offset).toBe(0);
                expect(result.rows[0].id).toBe('123-456-789');
                done();
            })
            .catch(function(err){
                expect(err).toBeUndefined();
                done();
            });
    });

});

output:

jasmine-node CouchIssue-spec.js
.F

Failures:

  1) PouchDB should retrieve a list of documents
   Message:
     timeout: timed out after 5000 msec waiting for spec to complete
   Stacktrace:
     undefined

Finished in 5.507 seconds
2 tests, 3 assertions, 1 failure, 0 skipped

output if I remove the % sign:

jasmine-node CouchIssue-spec.js
..

Finished in 0.063 seconds
2 tests, 5 assertions, 0 failures, 0 skipped

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