Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent slime from starting sldb on certain errors?

When serving large files from Clack/Hunchentoot with Slime connected, I sometimes see error messages like SB-IMPL::SIMPLE-STREAM-PERROR "Couldn't write to ~s"... Those are caused by the browser prematurely dropping connections (which is totally OK). The problem is that each time it happens, SLDB pops up. Which is annoying.

Is there a way I can inhibit certain errors in SLDB such as the above? I still would like to see them in an error log, but definitely not in SLDB.

like image 754
Mike Ivanov Avatar asked Feb 09 '23 04:02

Mike Ivanov


1 Answers

You can subclass PROCESS-CONNECTION for your acceptor and do your own error handling for this error.

Let's start by defining a custom acceptor:

(defclass no-error-acceptor (hunchentoot:acceptor)
  ())

Then we can create a wrapper around PROCESS-CONNECTION that inhibits printing of a message for this specific error:

(defmethod hunchentoot:process-connection ((acceptor no-error-acceptor) (socket t))
  (handler-case
      (call-next-method)
    (sb-impl::simple-stream-perror (condition)
      ;; Perhaps log the error here?
      nil)))

Make sure you actually start the server using this acceptor in order for it to be used.

like image 197
Elias Mårtenson Avatar answered Mar 08 '23 14:03

Elias Mårtenson