dom96 / httpbeast

A highly performant, multi-threaded HTTP 1.1 server written in Nim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash when "data.sendQueue.len == 0" or "data.sendQueue.len - sendQueueBefore > 0"

ThomasTJdev opened this issue · comments

assert == false stops my program when running in -d:dev. This happens almost randomly - sometimes on the first request, other times on 10th request when I refresh rapidly.

I am loading quite a few local files:

  • 6 x CSS
  • 8 x JS
  • 5 x API calls which are initiated by 1 of the JS files with jQuery ajax as async

I have tried to disable the API calls, but no difference. My next step will be to strip out the files 1-by-1 and after that minimizing the size of the HTML page. Unless you can point me in another direction ;) ?

Errors

I am getting 2 different errors:

sendQueryBefore

jester.nim(462)          serve
httpbeast.nim(412)       run
httpbeast.nim(292)       eventLoop
asyncdispatch.nim(1511)  poll
asyncdispatch.nim(1277)  runOnce
asyncdispatch.nim(183)   processPendingCallbacks
asyncfutures.nim(216)    :anonymous
httpbeast.nim(212)       :anonymous
system.nim(3753)         failedAssertImpl
system.nim(3746)         raiseAssert
system.nim(2807)         sysFatal
Error: unhandled exception: 
0 < len(data.sendQueue) - sendQueueBefore Request needs a response. [AssertionError]

sendQueue

jester.nim(462)          serve
httpbeast.nim(412)       run
httpbeast.nim(285)       eventLoop
httpbeast.nim(162)       processEvents
system.nim(3753)         failedAssertImpl
system.nim(3746)         raiseAssert
system.nim(2807)         sysFatal
Error: unhandled exception: len(data.sendQueue) == 0  [AssertionError]

Solution

Compile options

compiling with --assertions:off or -d:release

Code

I can fix it by commenting out:

assert data.sendQueue.len == 0

and
assert data.sendQueue.len - sendQueueBefore > 0,

This is just a result of me being overly cautious. Many of these asserts no longer apply since I implemented pipelining support so I decided to simply remove them.