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

global group can deadlock requests if auth is not already cached #754

Open
hanskr opened this issue Nov 27, 2024 · 0 comments
Open

global group can deadlock requests if auth is not already cached #754

hanskr opened this issue Nov 27, 2024 · 0 comments

Comments

@hanskr
Copy link

hanskr commented Nov 27, 2024

When running Octokit with auth, and trying to concurrently perform 10+ operations, a deadlock will happen.
The reason: https://github.com/octokit/plugin-throttling.js/blob/main/src/index.ts#L30
10 concurrent in global. If this buffer is filled with 10 requests, and no auth token is present, the auth request will end up as number 11, and never run, again causing the 10 requests in the queue to wait forever.

Example code to reproduce:

const octokit = await (new App({
  appId,
  privateKey,
  Octokit: Octokit.defaults({
    baseUrl,
  }),
})).getInstallationOctokit(installationId);

const artifacts = [
  'test-1',
  'test-2',
  'test-3',
  'test-4',
  'test-5',
  'test-6',
  'test-7',
  'test-8',
  'test-9',
  'test-10'
];

//await fetchLastSuccessfulDeployment('fis', 'ban', 'Finn', 'horizontal');
await Promise.all(
  artifacts.map(async (artifact) => {
    return await await octokit.rest.actions.listWorkflowRuns({
      owner: 'owner',
      repo: 'repo',
      workflow_id: `deploy.${artifact}.yaml`,
    });
  })
);

This will hang forever.

By reducing the array to 9 elements, it works.
By awaiting a single request before looping, it works (remove the comment before the loop, this will get a token and cache it).
By changing maxConcurrent to 11, it works.

I think it would be a good idea to let auth requests have its own queue, and not end up in the global one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant