You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(npmjs): follower hangs when doing a backfill (#1723)
(Re-roll of #1721 which was accidentally merged; in the previous version
I still did a `throw` from a non-`new Promise()` callback, which made
the exception uncaught. Solve in this one by more strictly splitting out
the Promise conversion to helper functions)
For reasons of the NPMJS replica behaving strangely[1], our follower has
changed to starting a full backfill of the entire catalog.
However, when doing the full backfill we're seeing strange behavior:
when doing fetches for a lot of packages in parallel, we notice that the
follower stops printing anything and the Lambda just times out after 5
minutes of inactivity. Looking at the logs, 47 requests are sent out in
parallel but only 15 are answered, and then nothing more happens.
Looking at the code it is a mess of NodeJS event handling, and from what
I can tell there is no handling of socket error events that occur in the
request (just socket error events that occur in the response). Best
theory: since these events are dropped on the floor, the corresponding
Promise is never resolved or rejected and the follower will just hang.
There also was no request timeout, I added that as well.
I refactored the code to be more straightforward:
- No recursion to do retries but a `while` loop
- Use a deadline-driven timeout (previous code would retry indefinitely)
- Put the classification of what makes an error retryable in once place
- Introduce helper functions to handle the conversion between callback
style and `async/await`.
- Importantly: add `req.on('error')` and `req.on('timeout')` to handle
problems with the request.
- Replace `x = new Error(); Error.captureStackTrace(x); ko(x)` with
`throw new Error()`, since we can now do that.
[1]:
https://github.com/orgs/community/discussions/152515#discussioncomment-13053455
----
*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*
---------
Signed-off-by: github-actions <github-actions@github.com>
Co-authored-by: github-actions <github-actions@github.com>
0 commit comments