Open doublerebel opened 7 years ago
Yes, I think the root problem here is that although Node's http client library provides an abort()
method, neither the underlying restify client nor the Manta client actually returns a request object, so there's no handle on which to call abort (and certainly no path to invoking the built-in request.abort()
).
Have you considered using the .info()
method to make a HEAD request instead? Then you would make a GET request only if needed. It's an oversight the .info()
method isn't documented -- I believe it's reasonably widely used.
Hello,
I have a situation where I'm syncing with manta directly to/from from http streams. The main issue is, there doesn't seem to be an official way to abort the GET request. I've traced up and down the stack, and the best way seems to be to call
res.destroy()
.Why I need it:
stream
from Manta). I need the file metadata, so I can't just.ls()
the directory.res.destroy()
)Where the problem is:
If I don't abort the request, I eventually receive this error to my error handler, I assume because I left an open connection:
but, there appears to be retry logic where the original
res
is left behind and a new download is started, and I have no way to access the newres
. This is whereno_resume
comes in: https://github.com/joyent/node-manta/blob/master/lib/client.js#L870When the connection is interrupted and the download auto-retries, the new
res
never is passed to a callback because the callback is restricted byonce
: https://github.com/joyent/node-manta/blob/master/lib/client.js#L818Therefore I can't cancel the new
res
because I have no access to it. If Ipause()
the stream it eventually resets the connection, if Idestroy()
orend()
the stream I get awrite after end
error.I've searched through the codebase but I don't see another way.
no_resume
doesn't really seem to be a solution because I need to download the file despite a dodgy connection. Is there something I'm missing? My initial thought is to just add a cancel/abort method to thestream
object that is passed to the callback, which takes action on the currentres
.EDIT: I did just discover
minfo
, which has doc notes in the .js file but is not documented in the Node SDK docs. Useful but doesn't exactly solve my problem.EDIT 2: I forgot to mention, I also looked through all through restify-client and find no specific way to abort requests in restify-client.