Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to switch root url to query2.finance.yahoo.com #426

Closed
okomarov opened this issue Mar 4, 2022 · 5 comments · Fixed by #109
Closed

Allow to switch root url to query2.finance.yahoo.com #426

okomarov opened this issue Mar 4, 2022 · 5 comments · Fixed by #109
Labels
enhancement New feature or request released

Comments

@okomarov
Copy link

okomarov commented Mar 4, 2022

Feature Request

For context, I started getting EAI_AGAIN errors in production which imply DNS resolution issues. This Stack Overflow post suggests that to resolve/mitigate the issue we could try to switch over to query2.finance.yahoo.com instead of the usual query1.finance.yahoo.com.

The major difference is that query2 is HTTP/1.1 compatible which works better with proxies, e.g. Cloudflare.

Wanted Feature

A (global?) option which allows to select which root URL to use or to pass your own root.

@okomarov okomarov added the enhancement New feature or request label Mar 4, 2022
@gadicc
Copy link
Owner

gadicc commented Mar 6, 2022

Thanks, agree, this will probably help me decide what to do finally with #109.

And I guess what what you said in mind, we should use query2 by default.

@gadicc
Copy link
Owner

gadicc commented Mar 6, 2022

P.S. In the meantime you could probably do something like the following (untested):

if (!yahooFinance._fetchOrig) {
  yahooFinance._fetchOrig = yahooFinance._fetch;
  yahooFinance._fetch = function proxyFetch(urlBase, ...args) {
    urlBase = urlBase.replace(/query1/, 'query2');
    return this._fetchOrig(urlBase, ...args);
  };
}

@gadicc
Copy link
Owner

gadicc commented Mar 6, 2022

This will be in our next release. There'll be an automated notice here when that happens.

@gadicc
Copy link
Owner

gadicc commented Mar 6, 2022

🎉 This issue has been resolved in version 2.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gadicc gadicc added the released label Mar 6, 2022
@gadicc
Copy link
Owner

gadicc commented Mar 6, 2022

As per https://github.com/gadicc/node-yahoo-finance2/blob/devel/docs/other/setGlobalConfig.md#options-not-documented-elsewhere, you can now:

yahoo-finance.setGlobalConfig({
  YF_QUERY_HOST: "query2.yahoo.finance.com" // default
});

or set the YF_QUERY_HOST environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants