gadicc / node-yahoo-finance2

Unofficial API for Yahoo Finance
https://www.npmjs.com/package/yahoo-finance2
MIT License
388 stars 62 forks source link

Support (asynchronous) cookie jars #670

Closed gadicc closed 1 year ago

gadicc commented 1 year ago

As pointed out by @z3nful in https://github.com/gadicc/node-yahoo-finance2/pull/667#issuecomment-1716757932, we really shouldn't need to fetch a new cookie on every new startup. This is especially an issue for serverless functions which are short-lived.

This has always been the plan; file-system and even database storage. The slightly more time consuming challenge is the initial cookie code was all programmed as synchronous calls, so it requires a little more work to change the whole flow to work asynchronously.

Leaving this open for now but anyone else is welcome to take a look too. Since we use https://www.npmjs.com/package/tough-cookie internally, we should just support any of their async cookie stores. However, we may need some async bridge code to ensure everything is set up correctly and in the correct order.

Bad gadicc! This should have all been in a separate branch / pull request, not separate commits. My apologies :sweat_smile:

gadicc commented 1 year ago

Shippable. The missing items aren't related to this feature specifically, but in getCrumb in general, and should be addressed elsewhere.