Skip to content

Commit ef07d93

Browse files
committed
fix: avoid extra async config lookup when repository is provided
Combine the starter and repositoryName resolution into a single getSliceMachineConfig() call, and only attempt it when repositoryName is not already provided by the caller. This avoids an additional async file traversal in the init error path, which was causing timing-sensitive tests to fail. Made-with: Cursor
1 parent 8aebe4f commit ef07d93

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

packages/manager/src/managers/telemetry/TelemetryManager.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,18 @@ export class TelemetryManager extends BaseManager {
102102
async track(args: TelemetryManagerTrackArgs): Promise<void> {
103103
const { event, repository, _includeEnvironmentKind, ...properties } = args;
104104
let repositoryName = repository;
105+
let starter: string | undefined;
105106

106107
if (repositoryName === undefined) {
107108
try {
108-
repositoryName = await this.project.getRepositoryName();
109-
} catch (error) {
110-
// noop, happen only when the user is not in a project
109+
const config = await this.project.getSliceMachineConfig();
110+
repositoryName = config.repositoryName;
111+
starter = config.starter;
112+
} catch {
113+
// noop, happens only when the user is not in a project
111114
}
112115
}
113116

114-
let starter: string | undefined;
115-
try {
116-
const config = await this.project.getSliceMachineConfig();
117-
starter = config.starter;
118-
} catch {
119-
// noop, happen only when the user is not in a project
120-
}
121-
122117
let environmentKind: Environment["kind"] | "_unknown" | undefined =
123118
undefined;
124119
if (_includeEnvironmentKind) {

0 commit comments

Comments
 (0)