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
using SimpleBufferStream, CodecZlib
# Create a dummy file to read from, this is the compressed HTTP body
file ="no-gzip"write(file, "this is not gzipped")
io =open(file)
# Intermediate bufferstream so that we can read/write in chunks
buf = SimpleBufferStream.BufferStream()
decompressor =GzipDecompressorStream(buf)
# Write body into the decompressor, which decompresses into buf
tsk =@asyncbegintrywrite(decompressor, io) # Doesn't throwfinallyclose(decompressor) # This throws *before* closing bufendendwrite(stderr, buf) # Deadlocks because buf is never closedwait(tsk)
The problem here is that there is a deadlock if the content can't be decompressed, e.g. if the content isn't gzipped to begin with. What happens is that write(decompressor, io) works, but then changemode! inside of close(decompressor) errors. Specifically,
Ultimately this means that tsk fails, but since buf is still open, write(stderr, buf) deadlocks.
I found that using something like
tsk =@asyncbegintrywrite(decompressor, io)
finallytryclose(decompressor)
catchclose(buf) # explicity close buf in case of errors in close(decompressor)rethrow()
endendend
mitigates the issue but doesn't really seem like a satisfactory solution.
The text was updated successfully, but these errors were encountered:
This is perhaps not a bug report, but looking for input on how to improve.
HTTP.jl uses the following pattern for decompressing request bodies (see https://github.com/JuliaWeb/HTTP.jl/blob/master/src/clientlayers/StreamRequest.jl#L122-L140):
The problem here is that there is a deadlock if the content can't be decompressed, e.g. if the content isn't gzipped to begin with. What happens is that
write(decompressor, io)
works, but thenchangemode!
inside ofclose(decompressor)
errors. Specifically,TranscodingStreams.jl/src/stream.jl
Line 182 in 35edb68
false
, meaning that https://github.com/JuliaIO/TranscodingStreams.jl/blob/master/src/stream.jl#L186-L188 is never executed.Ultimately this means that
tsk
fails, but sincebuf
is still open,write(stderr, buf)
deadlocks.I found that using something like
mitigates the issue but doesn't really seem like a satisfactory solution.
The text was updated successfully, but these errors were encountered: