Closed leedavidcs closed 4 years ago
Thanks for noticing, I'm having trouble reproducing this issue. Based on the request mentioned above, it seems like you are chaining the methods as shown below and making the calls sequentially. I've tried to reproduce the behavior and it's working as expected. Could you show me your code on the very last call? Appreciate the find.
iex
.batchSymbols("googl")
.batch()
.balanceSheet()
.book()
.cashFlow()
.ceoCompensation()
.company()
.earnings()
.estimates()
.financials()
.range()
.then(res => console.log(res));
iex
.batchSymbols("googl")
.batch()
.fundOwnership()
.income()
.largestTrades()
.logo()
.news()
.options()
.peers()
.price()
.range()
.then(res => console.log(res));
iex
.symbol()
.batch()
.quote()
.range("1m", 0)
.then(res => console.log(res));
@JBooker10 Thanks for the quick reply.
This isn't my exact code, but I've reproduced the error here minimally:
import fetch from "isomorphic-unfetch";
import { IEXCloudClient } from "node-iex-cloud";
const debugFetch = (requestInfo: RequestInfo) => {
console.log(requestInfo);
return fetch(requestInfo);
};
const iex = new IEXCloudClient(debugFetch, {
sandbox: true,
publishable: "***",
version: "stable"
});
const doTheThing = () => {
const batch1 = iex.batchSymbols("googl").batch().company();
const batch2 = iex.batchSymbols("googl").batch().company();
const batch3 = iex.batchSymbols("googl").batch().company();
Promise.all(
[batch1, batch2, batch3].map((batch) => batch.range())
).then(() => process.exit(0));
};
doTheThing();
Interestingly, it seems like this crashes on the 2nd call. However, it seems to work when I do not wrap it all within a Promise.all, and await them individually.
I guess I should a void making multiple requests at the same time (also since IEX Cloud has request limits).
Should this be documented somewhere instead?
If you chain the .range()
method on the variables themselves instead of when mapping them out this should work with no side effects. But yes it does return a 429 Too Many Requests
when you're making many request at a time.
example:
const doTheThing = () => {
const batch1 = iex
.batchSymbols("googl")
.batch()
.company()
.range();
const batch2 = iex
.batchSymbols("googl")
.batch()
.company()
.range();
const batch3 = iex
.batchSymbols("googl")
.batch()
.company()
.range();
Promise.all([batch1, batch2, batch3].map(batch => batch)).then(() =>
process.exit(0)
);
};
@JBooker10 Gotcha. Well, I'm good to resolve this issue in that case. Thanks!
Hi.
When calling
batchSymbols
, I get an error:Error: Not Found
when it is invoked for the 3rd time. This does not happen for single symbols usingsymbol
.When overwriting
fetch
to output the request info, I see that the 3rd request has a bad url.Output (3 urls are logged at the top):
This seems to only happen when the 3rd call is made from the same IEXCloudClient instance. So, I can work around this by creating a new IEXCloudClient instance every batch request.