Hello guys, just a small update.
Recently I took over a project developed months ago by another team. It was a NodeJS codebase with a lot of dependencies, one of which was the npm request module.
As a feature required us to stop the request midway (if some condition has been met), we realised we knew nothing about stopping the request!
Well indeed, at the time of writing, if you take a look at request’s documentation (which is also its README), you probably won’t find anything about stopping a request midway. Either that, or I have a serious issue with my eyesight.
Of course, this is just a matter of documenting. A bit of source code reading easily reveals that the request object has these methods available:
Out of the 3 that I tried, only
abort() did what I wanted. I called it somewhere during the handler functions for the
data events, and it did stop the request operation.
So, if you’re facing a similar case, I hope this may shed a bit light into matters at hand. I’ll probably open a pull request to update their documentation, but if any of you could do it, please go ahead & pay it forward! 🙂