Commit d71a90b

Anton Golub <antongolub@antongolub.com>
2025-06-25 10:13:21
ci: use `legacy` channel for publish (#1245) tag: 7.2.4 v7
* ci: use `legacy` channel for publish * fix: fix `expBackoff` implementation
v7
1 parent 1cc78bc
Changed files (3)
.github/workflows/v7-publish.yml
@@ -29,4 +29,4 @@ jobs:
       - run: echo "//wombat-dressing-room.appspot.com/:_authToken=$AUTH_TOKEN" >> .npmrc
         env:
           AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
-      - run: npm publish --provenance --access=public --no-git-tag-version --tag v-7
+      - run: npm publish --provenance --access=public --no-git-tag-version --tag legacy
src/goods.ts
@@ -166,13 +166,15 @@ export async function retry<T>(
   throw lastErr
 }
 
-export function* expBackoff(max: Duration = '60s', rand: Duration = '100ms') {
+export function* expBackoff(
+  max: Duration = '60s',
+  delay: Duration = '100ms'
+): Generator<number, void, unknown> {
   const maxMs = parseDuration(max)
-  const randMs = parseDuration(rand)
-  let n = 1
+  const randMs = parseDuration(delay)
+  let n = 0
   while (true) {
-    const ms = Math.floor(Math.random() * randMs)
-    yield Math.min(2 ** n++, maxMs) + ms
+    yield Math.min(randMs * 2 ** n++, maxMs)
   }
 }
 
README.md
@@ -37,7 +37,7 @@ gives sensible defaults.
 ## Install
 
 ```bash
-npm install zx@7 # or npm install zx@v-7
+npm install zx
 ```
 **Requirement**: Node.js >= 16.0.0