From fc2949837202a299f87549638fffbee7ca95e000 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Tue, 28 Jul 2026 02:03:17 +0000 Subject: [PATCH 1/2] fix: fetch the profile for telemetry only when telemetry is enabled Every CLI invocation fired a fire-and-forget /profile request even with telemetry disabled, since the call sat outside the telemetry gates. In CI this put every spawned CLI process on user-service concurrently, which starts returning 500s at roughly eight concurrent same-user requests. Co-Authored-By: Claude Fable 5 --- src/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 5a88eac..f0202d9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -115,12 +115,13 @@ async function main(): Promise { if (!help) { const { token, host } = await getCredentials(); - const telemetryEnabled = await isTelemetryEnabled(); + const telemetryEnabled = env.PRISMIC_TELEMETRY_ENABLED ?? (await isTelemetryEnabled()); + const sentryEnabled = env.PRISMIC_SENTRY_ENABLED ?? (telemetryEnabled && env.PROD); - if (env.PRISMIC_SENTRY_ENABLED ?? (telemetryEnabled && env.PROD)) { + if (sentryEnabled) { await initSentry({ host, repo }); } - if (env.PRISMIC_TELEMETRY_ENABLED ?? telemetryEnabled) { + if (telemetryEnabled) { await initTracking({ host, repo }); } @@ -132,7 +133,7 @@ async function main(): Promise { process.on("exit", () => spawnTokenRefresh()); } - if (!exp || exp > now) { + if ((sentryEnabled || telemetryEnabled) && (!exp || exp > now)) { getProfile({ token, host }) .then((profile) => { trackUser(profile); From fe45dddd192517520b2aed24b7b19943ce9a3172 Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Tue, 28 Jul 2026 18:08:26 +0000 Subject: [PATCH 2/2] test: run write-token tests sequentially Wroom's settings/security/token endpoint intermittently returns 500 when the same user fires concurrent write-token creates, which the concurrent test mode did across CI matrix jobs. Co-Authored-By: Claude Fable 5 --- test/token-create.test.ts | 21 ++++++++++++++++++--- test/token-delete.test.ts | 3 ++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/test/token-create.test.ts b/test/token-create.test.ts index b58ac62..441a395 100644 --- a/test/token-create.test.ts +++ b/test/token-create.test.ts @@ -44,7 +44,8 @@ it("creates an access token with --allow-releases", async ({ expect(auth!.scope).toBe("master+releases"); }); -it("creates a write token", async ({ expect, prismic, repo, token, host }) => { +// Wroom 500s under concurrent same-user write-token creates; keep this sequential. +it.sequential("creates a write token", async ({ expect, prismic, repo, token, host }) => { const { stdout, stderr, exitCode } = await prismic("token", ["create", "--write"]); expect(exitCode, stderr).toBe(0); expect(stdout).toContain("Token created:"); @@ -57,7 +58,14 @@ it("creates a write token", async ({ expect, prismic, repo, token, host }) => { expect(found).toBeDefined(); }); -it("creates a write token with a custom --name", async ({ expect, prismic, repo, token, host }) => { +// Wroom 500s under concurrent same-user write-token creates; keep this sequential. +it.sequential("creates a write token with a custom --name", async ({ + expect, + prismic, + repo, + token, + host, +}) => { const { stdout, stderr, exitCode } = await prismic("token", [ "create", "--write", @@ -75,7 +83,14 @@ it("creates a write token with a custom --name", async ({ expect, prismic, repo, expect(found!.app_name).toBe("My Seed Token"); }); -it("outputs a write token as JSON with --json", async ({ expect, prismic, repo, token, host }) => { +// Wroom 500s under concurrent same-user write-token creates; keep this sequential. +it.sequential("outputs a write token as JSON with --json", async ({ + expect, + prismic, + repo, + token, + host, +}) => { const { stdout, stderr, exitCode } = await prismic("token", ["create", "--write", "--json"]); expect(exitCode, stderr).toBe(0); diff --git a/test/token-delete.test.ts b/test/token-delete.test.ts index 35c773b..bb2e4b3 100644 --- a/test/token-delete.test.ts +++ b/test/token-delete.test.ts @@ -19,7 +19,8 @@ it("deletes an access token", async ({ expect, prismic, repo, token, host }) => expect(allAuths.find((a) => a.token === created.token)).toBeUndefined(); }); -it("deletes a write token", async ({ expect, prismic, repo, token, host }) => { +// Wroom 500s under concurrent same-user write-token creates; keep this sequential. +it.sequential("deletes a write token", async ({ expect, prismic, repo, token, host }) => { const created = await createWriteToken({ repo, token, host }); const { stdout, stderr, exitCode } = await prismic("token", ["delete", created.token]);