Closed SimonWoolf closed 5 years ago
Hey, thanks for reaching out, I wasn't able to replicate the infinite loop you are describing. Although, I was able to find that if you call abort too fast, then this method would be unavailable...
If you could kindly share a code of the problem that I would be able to replicate this scenario.
Thanks!
BTW from the description you gave this is the error I was able to replicate an exception: https://runkit.com/embed/da1q3tmfwi8k
However, no infinite loop, I will be able to fix this exception but I want to be sure I see the full picture.
The exception you got is just because you're doing req1.setTimeout(1,(req)=>req.abort())
, which is broken -- the setTimeout callback is just a listener for the timeout
event, it isn't fed the request as an argument. If you replace it with req1.setTimeout(1,()=>req1.abort())
, you'll see the stack overflow. https://runkit.com/simonwoolf/runkit-npm-http2-client
Sorry about my event handler mistake... middle of the night coding I wasn't seeing clearly =)
In any case I now see the bug... Thank you!
Fixed in #18 please close if agreed.
Thanks!
Don't think I agree it's fixed -- eg if you replace abort()
with close()
in the repro script you'll get the stack overflow again.
(But I'm no longer using this lib so have no vested interest here; up to you :slightly_smiling_face:)
close
is not part of http1 interface it was wrongly added and now removed.
Now we sync all public prototype functions of http1.
Example of how to reproduce: set the timeout to something low and do
req.on('timeout', () => req.abort())
.Lots of methods are stubbed, so they can be forwarded to the stream once the stream's actually been chosen. The problem comes if you call such a method after the stream has been chosen - for example,
abort()
, which forwards toclose()
. The stub callsthis.genericStubber()
, which checks forthis[$stubs]
-- which isn't present as it was set to null when the stream wastake()
n -- and defaults to just callingthis[method]();
. But that's justthis.close()
, which is the stub. So you get an infinite loop.