racket-rfc6455 icon indicating copy to clipboard operation
racket-rfc6455 copied to clipboard

`ws-send!` silently fails if the connection is closed

Open lexi-lambda opened this issue 1 year ago • 1 comments

The following program runs without errors:

#lang racket/base

(require net/rfc6455
         net/url)

(define done-sem (make-semaphore))

(void
 (ws-serve
  #:port 8080
  (λ (conn req)
    (printf "received ~v\n" (ws-recv conn))
    (ws-close! conn)
    (ws-send! conn "should be closed")
    (printf "sent\n")
    (semaphore-post done-sem))))

(sleep 1)
(define conn (ws-connect (string->url "http://localhost:8080/")))
(ws-close! conn)
(semaphore-wait done-sem)

Note that the server-side ws-send! succeeds despite occurring immediately after a use of ws-close!. This seems unhelpful.

lexi-lambda avatar Oct 09 '24 17:10 lexi-lambda