LeagueJS icon indicating copy to clipboard operation
LeagueJS copied to clipboard

Second call to league.Match.gettingById invisbly fails

Open bencooper222 opened this issue 5 years ago • 8 comments

I'm writing a basic tool to grab a list of matches from the past 24 hours and just console.log them right now. I'm successfully getting the matchlist with the encrypted summoner ID. Then, I'm getting the detailed data by getting with the matchID. I'm trying to do this for the entire matchlist but it only works for the first one in the matchlist. Running through a debugger, it appears that the code just mysteriously (and without an error) crashes at MatchEndpoint.js:48.

I'm sure that getting a summoner's list of matches and the details about them is a fairly solved challenge so I'm guessing this issue doesn't actually require a fix. That said, it seems like something wonky is going on with my use of your library - not my use of Promises and async/await more broadly.

My project is will be open so I have the luxury of sharing my code with you:

const league = new (require('leaguejs'))(process.env.LEAGUE_KEY);
const { season, queue } = require('./constants');

exports.getSummonerDataSince = async beginTime => {
  const matchList = (await league.Match.gettingListByAccount(
    process.env.LEAGUE_ACCOUNT_ID,
    process.env.LEAGUE_API_PLATFORM_ID,
    { beginTime },
  )).matches;

  const data = [];

  for (let match of matchList) data.push(await getGameData(match.gameId));

  return data;
};

const getGameData = async matchId => {
  console.log('start fetch');
  const fullData = await league.Match.gettingById(matchId);
  console.log('data fetched');
  return {
    season: season(fullData.seasonId),
    queue: queue(fullData.queueId),
    duration: fullData.gameDuration,
  };
};

// this code only printed out "start fetch", "data fetched", "start fetch"

bencooper222 avatar Apr 20 '19 00:04 bencooper222

Hi, thanks for reporting this.

Can you check if it works with 2.0.x (instead of 2.1.x)?

I changed something in the Api request, but it would be weird if that's the reason.

I'll check my own usage next week or sunday as Im using it for this use case too, although I think I use Bluebird.all/.map to resolve the matches instead of pushing awaits into an array. Shouldn't make a difference in theory.

Colorfulstan avatar Apr 20 '19 00:04 Colorfulstan

I don't think it's working any differently

bencooper222 avatar Apr 21 '19 23:04 bencooper222

Please try anyways, as it's no effort.

Colorfulstan avatar Apr 22 '19 07:04 Colorfulstan

I did try but I've since reworked my codebase to just make the RESTful calls directly to the service so I was trying these in a sample file with the newer and older version. It's possible there were differences between the sample file and my actual codebase. That said, I'm pretty sure both versions fail.

bencooper222 avatar Apr 23 '19 04:04 bencooper222

Ok, thanks. Ill check if I can reproduce with your sample code.

Colorfulstan avatar Apr 23 '19 07:04 Colorfulstan

Might be helpful; constants file imported in code: https://github.com/bencooper222/write-league-games-spreadsheet/blob/master/src/constants.js

bencooper222 avatar Apr 23 '19 08:04 bencooper222

The Issue is somehow related to the ratelimiter usign SPREAD Strategy. Im not sure if I get to look into that right away (I would like to rework that anyways...)

If you use burst (by passing into the leagueJS constructor const league = new (require('leaguejs'))(process.env.LEAGUE_KEY, {limits: {allowBursts:true}}); It works fine.

Thanks again for finding and reporting this issue.

Colorfulstan avatar Apr 24 '19 12:04 Colorfulstan

For my own reference: https://github.com/Colorfulstan/RiotRateLimiter-node/issues/10

Colorfulstan avatar Apr 24 '19 12:04 Colorfulstan