You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on #3276, I found an issue with app.Test() when a handler closes the underlying connection before returning from the handler. Since app.server.ServeConn(conn) fails to write to the connection when the connection is closed early, an error is instantly returned.
This issue sometimes occurs when using c.Drop() in a handler (especially in middlewares). Since c.Drop() closes the underlying connection before app.server.ServeConn() can write to it, it instantly returns an error.
This is also an issue for testing future features like manual response flushing via c.End() (#3276) and Early hints (#3211), where data is sent during the life of a handler. Since app.Test() assumes that an early connection is always an unrecoverable error, it won't allow proper testing of these features.
How to Reproduce
Create a handler that only has return c.Drop()
Call app.Test() for that handler.
You get an error "testConn is closed".
Expected Behavior
app.Test() should only return an error if the handler's response is empty or if the test failed on timeout.
If the closed connection results in an empty response (e.g. from c.Drop()), the error should be "test: got empty response" instead of the closed connection error.
Bug Description
While working on #3276, I found an issue with
app.Test()
when a handler closes the underlying connection before returning from the handler. Sinceapp.server.ServeConn(conn)
fails to write to the connection when the connection is closed early, an error is instantly returned.This issue sometimes occurs when using
c.Drop()
in a handler (especially in middlewares). Sincec.Drop()
closes the underlying connection beforeapp.server.ServeConn()
can write to it, it instantly returns an error.This is also an issue for testing future features like manual response flushing via
c.End()
(#3276) and Early hints (#3211), where data is sent during the life of a handler. Sinceapp.Test()
assumes that an early connection is always an unrecoverable error, it won't allow proper testing of these features.How to Reproduce
return c.Drop()
app.Test()
for that handler."testConn is closed"
.Expected Behavior
app.Test()
should only return an error if the handler's response is empty or if the test failed on timeout.If the closed connection results in an empty response (e.g. from
c.Drop()
), the error should be"test: got empty response"
instead of the closed connection error.Fiber Version
v3.0.0-beta.4
Code Snippet (optional)
Checklist:
The text was updated successfully, but these errors were encountered: