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

Unable to reserve big amount of links #315

Open
FreePhoenix888 opened this issue Mar 3, 2024 · 6 comments
Open

Unable to reserve big amount of links #315

FreePhoenix888 opened this issue Mar 3, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@FreePhoenix888
Copy link
Member

How to reproduce

await deep.reserve(5000)

Error

28 | };
29 | var ApolloError =  (function (_super) {
30 |     tslib.__extends(ApolloError, _super);
31 |     function ApolloError(_a) {
32 |         var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
33 |         var _this = _super.call(this, errorMessage) || this;
                         ^
ApolloError: http exception when calling webhook
      at new ApolloError (/workspace/dev/russian-laws/node_modules/@apollo/client/errors/errors.cjs:33:21)
      at /workspace/dev/russian-laws/node_modules/@apollo/client/core/core.cjs:1427:47
      at both (/workspace/dev/russian-laws/node_modules/@apollo/client/utilities/utilities.cjs:1269:31)
      at /workspace/dev/russian-laws/node_modules/@apollo/client/utilities/utilities.cjs:1260:72
      at new Promise (:1:21)
      at then (/workspace/dev/russian-laws/node_modules/@apollo/client/utilities/utilities.cjs:1260:24)
      at /workspace/dev/russian-laws/node_modules/@apollo/client/utilities/utilities.cjs:1271:36
      at notifySubscription (/workspace/dev/russian-laws/node_modules/zen-observable/lib/Observable.js:135:16)
      at onNotify (/workspace/dev/russian-laws/node_modules/zen-observable/lib/Observable.js:179:3)
      at next (/workspace/dev/russian-laws/node_modules/zen-observable/lib/Observable.js:235:7)
✗ import and export [32138.78ms]

 0 pass
 1 fail
Ran 1 tests across 1 files. [33.29s]
@FreePhoenix888
Copy link
Member Author

Note: I currently work on https://github.com/deep-foundation/russian-laws and have this problem. I guess as workaround I need to call reserve multiple times instead of one. Is this related to timeout? I do not see clear error. Can I change timeout?

@Konard
Copy link
Member

Konard commented Mar 3, 2024

@FreePhoenix888 did you created a test in deeplinks repository?

@Konard Konard added the bug Something isn't working label Mar 3, 2024
@Konard Konard moved this to Todo in Deep Architecture Mar 3, 2024
@FreePhoenix888
Copy link
Member Author

@FreePhoenix888 did you created a test in deeplinks repository?

not yet

@FreePhoenix888
Copy link
Member Author

FreePhoenix888 commented Mar 6, 2024

I tried to reserve 20 000 links by calling reserve a lot of times to reserve 500 links. After reserving 500 links four times (totally reserved 2000) I get "http exception when calling webhook"

@Konard
Copy link
Member

Konard commented Mar 11, 2024

Workaround 1

Chunk reversed links with less then 500 links.

@FreePhoenix888
Copy link
Member Author

Even if we do it in parallel we still get this error:

async function reserveItemsInBatches({
  totalItems,
  batchSize,
}: {
  totalItems: number;
  batchSize: number;
}) {
  const reservedIds = [];
  const numBatches = Math.ceil(totalItems / batchSize);

  const batchPromises = [];

  for (let i = 0; i < numBatches; i++) {
    const batch = Math.min(batchSize, totalItems - i * batchSize);
    batchPromises.push(deep.reserve(batch));
  }

  const batchResults = await Promise.all(batchPromises);

  batchResults.forEach(reserved => {
    reservedIds.push(...reserved);
    log(`Reserved ${reservedIds.length} / ${totalItems}`);
  });

  return reservedIds;
}

const reservedIds = await reserveItemsInBatches({
  totalItems: linksNumberToReserve,
  batchSize: 100,
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants