-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tasynchttpserver_transferencoding.nim is flaky #17456
Comments
I think this is the second or third time I've heard someone run into an issue with those tests, so clearly they're flaky - most likely a rare race condition. I haven't used Nim's async much since writing them, so I don't know what the best way to resolve is, and I don't really have the bandwidth to look into it. Does it make sense to just remove the tests? Or run them as an extended test set? |
@timotheecour I've got some bandwidth to take a look at this issue now if you have any guidance/suggestions on what kind of solution you'd like to see or any exploratory work that might be useful. Thanks! |
ya this keeps happening, and happens more lately for some reason, it's one of the most flaky tests. Before talking about a solution, a good next step would be:
as for the fix, it probably involves replacing Note that 1 sure way to fix this would be to start the server in another process (not hard to do), but we should still find a non-buggy way to start the server in the same process; but maybe this (using 2 processes instead of 1) would be a good temporary solution to fix the test |
Going to use this thread to document findings; maybe someone more knowledgeable than I am can help out if I'm missing something. First observation is that commenting out Next, I tried to re-write the test case based on what import httpclient, asynchttpserver, asyncdispatch, asyncfutures
import net
import std/nativesockets
proc genTest(input, expected: string): Future[(string, bool)] {.async.} =
var sanity = false
proc handler(request: Request) {.async.} =
doAssert(request.body == expected)
doAssert(request.headers.hasKey("Transfer-Encoding"))
doAssert(not request.headers.hasKey("Content-Length"))
sanity = true
await request.respond(Http200, "Good")
proc request(server: AsyncHttpServer): Future[AsyncResponse] {.async.} =
echo "hit 3a"
let client = newAsyncHttpClient()
echo "hit 3b"
let clientResponse = await client.request("http://localhost:64123/")
echo "hit 3c"
server.close()
echo "hit 3d"
return clientResponse
echo "hit 1"
let server = newAsyncHttpServer()
echo "hit 2"
discard server.serve(Port(64123), handler)
echo "hit 3"
let response = waitFor(request(server))
echo "hit 4"
let body = waitFor(response.body)
echo "hit 5"
return (body, sanity)
block:
echo "test"
const expected = "hello=world"
const input = ("b\r\n" &
"hello=world\r\n" &
"0\r\n" &
"\r\n")
let res = genTest(input, expected)
res.addCallback(proc(f: Future[(string, bool)]) = (
let (body, sanity) = f.read
echo "body: ", body, " sanity: ", sanity
))
when running, I get the following output:
There are no errors or other indication of why the program stopped, and I'm kind of stumped. |
see https://dev.azure.com/nim-lang/255dfe86-e590-40bb-a8a2-3c0295ebdeb1/_apis/build/builds/14578/logs/83 from #17209, on osx cpp CI.
the recently added tests/stdlib/tasynchttpserver_transferencoding.nim (from #16678) is flaky (ie, there is a bug)
/cc @vabresto
Current Output
on:
hostOS: macosx, hostCPU: amd64, int: 8, float: 8, cpuEndian: littleEndian, cwd: /Users/runner/work/1/s
Additional Information
1.5.1 c8dda86
links
originally reported in timotheecour#544
as noted there:
The text was updated successfully, but these errors were encountered: