Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/:db requests crash on unauthorized access #353

Closed
QuentinRoy opened this issue Oct 5, 2018 · 0 comments · Fixed by #354
Closed

/:db requests crash on unauthorized access #353

QuentinRoy opened this issue Oct 5, 2018 · 0 comments · Fixed by #354

Comments

@QuentinRoy
Copy link
Contributor

Requests seem to crash when trying to access unauthorized database with the following (not explanatory) error message:

(node:10101) UnhandledPromiseRejectionWarning: TypeError: Cannot set property 'instance_start_time' of undefined
    at /Users/qroy/Workspace/Code/personality-adaptation/node_modules/express-pouchdb/lib/routes/db.js:100:32
    at /Users/qroy/Workspace/Code/personality-adaptation/node_modules/promise-nodify/index.js:22:7
    at <anonymous>

After fiddling for a few hours with the code, I believe the error is due to pouchdb-size swallowing errors coming from previous handlers here:

}).catch(function () {
//surpress - .info() should keep functioning if for some reason
//it's impossible to get the disk_size.
return resp;
});

The catch is supposed to suppress exceptions when the db size can't be get, but actually swallow any exceptions thrown by orig. In particular, it swallows this one:

if (!checkAllowed(userCtx, security)) {
throw401();
}

When this happens resp (in pouchdb-size's catch block), isn't set yet, and the promise is resolved with undefined, resulting in the unexpected error above:

info.instance_start_time = startTime.toString();

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 a pull request may close this issue.

1 participant