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

Callback exceptions are swallowed #10

Open
vincentjames501 opened this issue Apr 26, 2017 · 0 comments
Open

Callback exceptions are swallowed #10

vincentjames501 opened this issue Apr 26, 2017 · 0 comments

Comments

@vincentjames501
Copy link

Issue

If there is an exception that is thrown inside of a http-kit response callback, nothing is ever logged anywhere (unless it is derefed).

Steps

(deftest exception-handling
  (testing "Inside fake-http"
    (fake-http/with-fake-http
      ["https://google.com" 200]
      (http/get "https://google.com"
                (fn [resp] (throw (Exception. "Inside logged?"))))))
  (testing "outside fake-http"
    (http/get "https://google.com"
              (fn [resp] (throw (Exception. "Outside logged?"))))))

Output

Ran 1 test containing 0 assertions.
No failures.
Wed Apr 26 16:05:48 CDT 2017 [client-worker-2] ERROR - GET https://www.google.com/'s callback
java.lang.Exception: Outside logged?

Possible Solution

Inside responder-wrapper it may just be appropriate to log similar to how http-kit does:

(try ((or callback identity) %1)
                                    (catch Throwable e
                                      ;; dump stacktrace to stderr
                                      (HttpUtils/printError (str method " " url "'s callback") e)
                                      ;; return the error
                                      {:opts opts :error e}))
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

No branches or pull requests

1 participant