opentok/opentok-node

Maximum call stack size exceeded is thrown after prolonged usage

rviscarra opened this issue · 0 comments

I ran into this issue where any method that involves the recording API will throw a RangeError: Maximum call stack size exceeded exception after the service has been used for a relatively long time.

Here's a fragment of code that will eventually throw the exception for an sufficiently large N:

const opentok = new OpenTok(TOKBOX_API_KEY, TOKBOX_API_SECRET);

async function getArchive(sessionId) {
  return new Promise((accept, reject) => {
    opentok.getArchive(sessionId, (err, archive) => {
      if (err) return reject(err);
      accept(archive);
    });
  });
}

async function loop() {
  for(let i = 0; i < N; i++) {
    await getArchive('session id');
  }
}

I was able to find the issue and will submit a PR soon.