tailhook / rotor-http

The mio/rotor based http server library for rust (UNMAINTAINED, use tk-http)
MIT License
110 stars 11 forks source link

assertion failed server/parser.rs:223 #40

Closed nokaa closed 8 years ago

nokaa commented 8 years ago

I received this error earlier:

thread '<main>' panicked at 'assertion failed: response.is_complete()', /home/nokaa/.multirust/toolchains/nightly/cargo/git/checkouts/rotor-http-aa821d917006c86c/master/src/server/parser.rs:223

At the time I was just sending data to a client, and I have not been able to replicate the error.

pyfisch commented 8 years ago

The relevant assertion can be found in the parser. After the request body is received a response should be sent. If the user does not send a complete response this assertion fails. This means either rotor-http's state machine is wrong at some point or your code does not send under some circumstances a complete response. Is your code public so I can take a look?

tailhook commented 8 years ago

I second what @pyfisch said. And regardless of whether this specific problem is a problem with rotor-http or user code. We will have such issues with user code anyway.

So the question is if we can do better at this? Allow sending broken request is bad, and an assertion is probably a good way to discover this early on during development.

On the other hand, returning None from any handler in case you can't do anything better (like can't fetch next portion of the data in the middle of a request), is just so tempting.

tailhook commented 8 years ago

If it wasn't clear I mean, we could:

  1. Fill response generation with some debug messages (so with RUST_LOG=debug you will get some mesages preceeding panic).
  2. Print exact state the request is currently in, before panicking
  3. Emit error log message instead of panic

(I'm pretty skeptical about (3) because this may delay when user will find out if there is something wrong with their code)

nokaa commented 8 years ago

@pyfisch The application code is here. The function called for sending data is here.

tailhook commented 8 years ago

@nokaa at least in cases Board(_) and Thread(_) nothing is sent. And this is the case for assertion. You should send 501 Not Implemented page or 404 error page instead of doing nothing in that cases until they are implemented.

tailhook commented 8 years ago

@nokaa Is this solved?

nokaa commented 8 years ago

It seems like it. I haven't run into this since. My apologoies for the late response.