bitcoin-core icon indicating copy to clipboard operation
bitcoin-core copied to clipboard

Add pool option to request.defaults

Open Totenfluch opened this issue 5 years ago • 2 comments

the pool option is required when handling hundreds of requests per seconds. Without the pool option ESOCKETTIMEDOUT will occur and cancel the queued requests.

https://www.npmjs.com/package/request#requestoptions-callback

pool - an object describing which agents to use for the request. If this option is omitted the request will use the global agent (as long as your options allow for it). Otherwise, request will search the pool for your custom agent. If no custom agent is found, a new agent will be created and added to the pool. Note: pool is used only when the agent option is not specified. A maxSockets property can also be provided on the pool object to set the max number of sockets for all agents created (ex: pool: {maxSockets: Infinity}). Note that if you are sending multiple requests in a loop and creating multiple new pool objects, maxSockets will not work as intended. To work around this, either use request.defaults with your pool options or create the pool object with the maxSockets property outside of the loop.

Totenfluch avatar Dec 26 '19 13:12 Totenfluch

the whole request option could also be enhanced by just passing a single options object that could just be passed through. As this would be a breaking change for existing users this PR is limited to adding this - in my opinion - important option.

Totenfluch avatar Dec 26 '19 13:12 Totenfluch

We will soon merge https://github.com/ruimarinho/bitcoin-core/pull/106 so maybe we can release this as patch and land a new options method in the upcoming major release.

ruimarinho avatar Dec 27 '19 02:12 ruimarinho