Repository navigation
Conversation
Since vercel#374, runCommand without detached sends its POST with retries off, so a network error or a 5xx cannot start a command twice. That also stopped a 429 from being retried, though the API turned the request away without starting the command. Send the POST again only after a 429, waiting the longer of Retry-After and the backoff, for at most 20 seconds in total. Fixes vercel#518 Signed-off-by: Yuuki <xcscxr@gmail.com>
Contributor
|
@xcscxr is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #518.
Since #374,
runCommandwithoutdetachedsends its POST withretry: { retries: 0 }, so a network error or a 5xx can't start a command twice (#363). That also turned off retrying a 429. This sends the POST again only after a 429, on the assumptionwriteCommandStdinalready makes for rate limited writes: the API turned the request away without starting the command.Retry-Afterand the backoff the stdin writes use (400 ms × 2ⁿ). A missingRetry-Afterdoesn't mean an immediate resend, and a server that keeps answeringRetry-After: 1gets 6 requests in about 13 seconds, not 21 in 20.withRetrywaits for oneRetry-After. Stdin writes cap the number of retries instead; capping the total keeps the timerunCommandspends waiting before it gives up to 20 seconds. When the next wait would pass it,runCommandrejects with the 429'sAPIError, as before.signalends the wait.stdinBackoffandwaitBeforeStdinRetryare renamed toretryBackoffandwaitBeforeRetry, since commands use them too now.Detached
runCommandis unchanged. It still goes throughwithRetry's default retries, which #363 and #364 are about.Tests
The new tests in
api-client.test.ts, underwhen the command is rate limited, fail without the change:Retry-After: withRetry-After: 3, sent at 0 and 3000 ms, then the command finishesRetry-After10, 1 and 0, sent at 0/10/20 s (the cap is inclusive), 0/1/2/3.6/6.8/13.2 s and 0/0.4/1.2/2.8/6/12.4 s, then rejects with the 429pnpm vitest runinpackages/vercel-sandbox: 471 passed, 83 skipped (the suites behindRUN_INTEGRATION_TESTS), withdistbuilt forpackage-exports.test.ts.pnpm typecheckpasses.