Skip to content

Commit ede7fa3

Browse files
committed
fix(export): generate clientId random suffix via node crypto, not a component dep
Using @teambit/toolbox.string.random added a new component-dependency edge to @teambit/export (a core, widely-depended aspect). Combined with the recent dependency-resolution changes on master, that edge perturbs the dogfooding 'bit ci pr' capsule build of export's dependents (lanes/snapping mock-remote tests started failing with InvalidScopeNameFromRemote). Get the random suffix from node's built-in crypto instead — same collision-safe clientId, no new component dependency.
1 parent 5b96951 commit ede7fa3

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

scopes/scope/export/export.main.runtime.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import crypto from 'crypto';
12
import fs from 'fs-extra';
23
import type { CLIMain } from '@teambit/cli';
34
import { CLIAspect, MainRuntime } from '@teambit/cli';
@@ -14,7 +15,6 @@ import { ComponentsList } from '@teambit/legacy.component-list';
1415
import type { RemoveMain } from '@teambit/remove';
1516
import { RemoveAspect } from '@teambit/remove';
1617
import { hasWildcard } from '@teambit/legacy.utils';
17-
import { generateRandomStr } from '@teambit/toolbox.string.random';
1818
import type { Workspace } from '@teambit/workspace';
1919
import { WorkspaceAspect, OutsideWorkspaceError } from '@teambit/workspace';
2020
import type { Logger, LoggerMain } from '@teambit/logger';
@@ -685,8 +685,10 @@ if the scope name is wrong and you've already snapped/tagged, run "bit reset" to
685685
// millisecond (e.g. concurrent CI runners pushing the same lane) get the same clientId, share one
686686
// pending-dir, collapse the queue to a single entry, and both validate against the pre-persist
687687
// state, silently losing one runner's update. A random suffix keeps the timestamp prefix (so the
688-
// sorted queue still roughly preserves arrival order) while guaranteeing uniqueness.
689-
const clientId = resumeExportId || `${Date.now()}-${generateRandomStr()}`;
688+
// sorted queue still roughly preserves arrival order) while guaranteeing uniqueness. Use node's
689+
// built-in `crypto` rather than a component helper so this core aspect doesn't gain a new
690+
// component dependency (which perturbs the dogfooding capsule dependency graph of its dependents).
691+
const clientId = resumeExportId || `${Date.now()}-${crypto.randomBytes(8).toString('hex')}`;
690692
await this.pushRemotesPendingDir(clientId, manyObjectsPerRemote, resumeExportId);
691693
await validateRemotes(remotes, clientId, Boolean(resumeExportId));
692694
// Intentionally no cleanup on `persistRemotes` failure: pending dirs are the substrate for

0 commit comments

Comments
 (0)