res.json not returning? #4

6a68 opened this Issue Jul 9, 2013 · 2 comments


None yet
2 participants

6a68 commented Jul 9, 2013

Have been debugging restmail this morning, thought I'd log a bug for the latest thing instead of leaving its history undocumented.

It looks like redis is fine, forever list shows reasonable uptime for the emailserver.js and webserver.js processes, and the emailserver log is quiet.

But the webserver log has lots and lots of entries of the form - - [Tue, 09 Jul 2013 19:35:15 GMT] "GET /mail/bidpom_68319f9e-e8ce-11e2-91bc-406c8f3aa05a HTTP/1.1" 200 2 "-" "python-requests/0.13.3 CPython/2.7.1 Darwin/11.4.2"
TypeError: Cannot call method 'lrange' of null
    at /home/app/code/webserver.js:39:6
    at callbacks (/home/app/code/node_modules/express/lib/router/index.js:272:11)
    at param (/home/app/code/node_modules/express/lib/router/index.js:246:11)
    at param (/home/app/code/node_modules/express/lib/router/index.js:243:11)
    at pass (/home/app/code/node_modules/express/lib/router/index.js:253:5)
    at Router._dispatch (/home/app/code/node_modules/express/lib/router/index.js:280:4)
    at Object.handle (/home/app/code/node_modules/express/lib/router/index.js:45:10)
    at next (/home/app/code/node_modules/express/node_modules/connect/lib/http.js:203:15)
    at Object.logger [as handle] (/home/app/code/node_modules/express/node_modules/connect/lib/middleware/logger.js:155:5)
    at next (/home/app/code/node_modules/express/node_modules/connect/lib/http.js:203:15)

What's odd is that the affected code should never be reached: it should bail at if (!db) res.json([]), but it doesn't--it keeps on trucking.

Taking a break, then we'll get back to this.


seanmonstar commented Jul 9, 2013

That's because res.json doesn't stop the rest of the function from executing. All it does is send some JSON down the response pipe. You'll need to add a return inside the if block, if you want it to stop there.


6a68 commented Jul 9, 2013

grr. now I can't repro. I assume this was something like, forever restartall failed to let go of the redis port, the new process couldn't connect, barfed and set db to null, and on we went.

doing post-update a couple of times seems to have fixed this. I'll still file a bug to fix the res.json funk. thanks for the input @seanmonstar

6a68 added a commit to 6a68/ that referenced this issue Jul 9, 2013

@6a68 6a68 closed this in b4a51e0 Aug 6, 2013

rfk added a commit that referenced this issue Aug 6, 2013

Merge pull request #10 from 6a68/nodb
Handle missing db properly in test and prod. Fixes #4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment