Running a simple example based on the `httpbeast 0.2.2` framework made an error 
:`getData.headersFinished` Selector not ready to send.[AssertionDefect].

My code is as follows:
    
    
    import segfaults
    import random
    
    import options, asyncdispatch
    
    import httpbeast
    
    proc onRequest(req: Request): Future[void] {.async.} =
      if req.httpMethod == some(HttpGet):
        case req.path.get()
        of "/":
          randomize()
          let t = rand(999)
          await sleepAsync(t)
          req.send("Hello World")
        else:
          req.send(Http404)
    
    run(onRequest)
    
    
    Run

The errors I have obtained are as follows: 
    
    
    Starting 6 threads
    Listening on port 8080
    /home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(287) eventLoop
    /home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(166) processEvents
    /home/lhf/Nim-devel/lib/pure/asyncdispatch.nim(1626) poll
    /home/lhf/Nim-devel/lib/pure/asyncdispatch.nim(1367) runOnce
    /home/lhf/Nim-devel/lib/pure/asyncdispatch.nim(208) processPendingCallbacks
    /home/lhf/Nim-devel/lib/pure/asyncmacro.nim(22) onRequestNimAsyncContinue
    /home/lhf/桌面/t.nim(15) onRequestIter
    /home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(342) send
    /home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(321) send
    /home/lhf/Nim-devel/lib/system/assertions.nim(30) failedAssertImpl
    /home/lhf/Nim-devel/lib/system/assertions.nim(23) raiseAssert
    /home/lhf/Nim-devel/lib/system/fatal.nim(49) sysFatal
    [[reraised from:
    /home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(287) eventLoop
    /home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(166) processEvents
    /home/lhf/Nim-devel/lib/pure/asyncdispatch.nim(1626) poll
    /home/lhf/Nim-devel/lib/pure/asyncdispatch.nim(1367) runOnce
    /home/lhf/Nim-devel/lib/pure/asyncdispatch.nim(208) processPendingCallbacks
    /home/lhf/Nim-devel/lib/pure/asyncfutures.nim(281) :anonymous
    /home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(223) :anonymous
    /home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(94) 
onRequestFutureComplete
    ]]
    Error: unhandled exception: 
/home/lhf/.nimble/pkgs/httpbeast-0.2.2/httpbeast.nim(321, 10) 
`getData.headersFinished` Selector not ready to send. [AssertionDefect]
    
    
    Run

Reply via email to