orthecreedence / wookie

Asynchronous HTTP server in common lisp
http://wookie.lyonbros.com/
MIT License
189 stars 19 forks source link

error handling #47

Closed nightshade427 closed 10 years ago

nightshade427 commented 10 years ago

I read the docs but can't seem to get error handling working and not leaving a client hung when there is an error. It looks like error.lisp line 47 should send response to client if error is unhandled? I put a break in main handler in error.lisp and it doesn't seem to even get called if there is an error, only when call succeeds.

nightshade427 commented 10 years ago

Looks like if error is in route itself main handler fires and error handler. But, if the error is in code that the route calls them it just hangs.

nightshade427 commented 10 years ago

Actually if I do this it works and drops me to debugger.

(DEFROUTE (:GET "/xxxx")
    (REQ RES)
  (ALET* ((param (GET-VAR REQ "param"))
          (RESULT (PROGN (do-stuff-that-causes-error))))
    (SEND-RESPONSE RES :BODY RESULT :HEADERS '(:CONTENT-TYPE "text/plain"))))

But, if I do this it hangs client and I don't get debugger.

(DEFROUTE (:GET "/xxxx")
    (REQ RES)
  (ALET* ((param (GET-VAR REQ "param"))
          (RESULT (PROGN (do-stuff))))
    (error "hangs")
    (SEND-RESPONSE RES :BODY RESULT :HEADERS '(:CONTENT-TYPE "text/plain"))))
orthecreedence commented 10 years ago

I'll investigate this when I get home tonight. The global error handler should be catching that error, even if you're not locally wrapping in future-handler-case.

nightshade427 commented 10 years ago

Awesome, thanks :)

gtod commented 10 years ago

I ran some tests but did not have the same issues. nightshade427 could you grab https://gist.github.com/gtod/10210207 and see how you go with it? I found that /index.html just worked, /foo and /bar returned the appropriate messages and /whatever etc. was also trapped.

There are a few comments at the base of that gist which may explain the issues you had, may not. Of course, please excuse me if I'm barking right up the wrong tree...

orthecreedence commented 10 years ago

Sorry for the lag here, guys, been a busy few days with work and life stuff. I'll try to take a look at this tomorrow and see if I can give a definitive answer on what's going on.

@nightshade427 can you make sure you have the latest git versions of Wookie, cl-async, and cl-async-future?