Repository navigation
Closed
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
- Open the GitHub details in Settings under Source control & issues on an environment with a 1Password secret provider.
- Use a 1Password reference for the GitHub token.
- Start checking the reference while 1Password is slow to answer.
- Replace the reference with another valid reference and press Enter.
- Start checking the second reference.
- Restore the first reference and press Enter.
- Start a new check of the first reference before the original check replies.
- Watch the check indicator when the original reply arrives.
Expected behavior
The indicator stays pending until the most recent check answers.
Actual behavior
The first reply replaces the pending indicator with its old result.
Impact
Minor bug or occasional failure. Users comparing secret references during a slow lookup can see a premature failure or success when they return to a reference and check it again.
Version or commit
main at db9efc5cf0. The cause is at apps/web/src/components/settings/SecretSourceInput.tsx:162.
Environment
Linux x64 boat.dev default machine, a fresh checkout.
Logs or stack traces
The newer secret check is still pending after the earlier replyAutomated repro
Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.
diff --git a/scripts/scenarios/secret-check-keeps-new-attempt-pending.e2e.ts b/scripts/scenarios/secret-check-keeps-new-attempt-pending.e2e.ts
new file mode 100644
index 0000000000..35dbadb220
--- /dev/null
+++ b/scripts/scenarios/secret-check-keeps-new-attempt-pending.e2e.ts
@@ -0,0 +1,138 @@
+/// <reference lib="dom" />
+import { SecretProviderId, SecretProviderKind } from "@t3tools/contracts";
+import { expect } from "e2e";
+import * as Effect from "effect/Effect";
+import * as FileSystem from "effect/FileSystem";
+
+import { T3_HOME } from "../e2e.config.ts";
+import { environmentId, rpcClient, runPromise, test, WEB } from "./t3.ts";
+
+const PROVIDER = SecretProviderId.make("scenario");
+const REFERENCE_A = "op://Scenario/GitHub/first";
+const REFERENCE_B = "op://Scenario/GitHub/second";
+
+declare global {
+ interface Window {
+ secretCheckGate?: {
+ readonly count: () => number;
+ readonly finishFirst: () => Promise<void>;
+ };
+ }
+}
+
+test(
+ "An earlier check of the same reference leaves the new check pending",
+ WEB,
+ async ({ t3, app, browser, screen }) => {
+ const origin = app.baseUrl ?? "";
+ const environment = await runPromise(environmentId(origin));
+ await t3.project("demo");
+ await runPromise(
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ yield* fs.writeFileString(`${T3_HOME}/bin/op`, "#!/bin/sh\nexit 1\n");
+ yield* fs.chmod(`${T3_HOME}/bin/op`, 0o755);
+ const client = yield* rpcClient(T3_HOME, origin);
+ yield* client["server.updateSettings"]({
+ patch: {
+ secretProviders: {
+ [PROVIDER]: {
+ kind: SecretProviderKind.make("one_password"),
+ label: "Scenario",
+ config: { account: "scenario" },
+ },
+ },
+ sourceControlHosts: {
+ github: {
+ tokens: {
+ "github.com": {
+ provider: PROVIDER,
+ reference: REFERENCE_A,
+ },
+ },
+ },
+ },
+ },
+ });
+ }).pipe(Effect.scoped),
+ );
+
+ // Delay the real checks independently so only the older A can produce a reply.
+ await browser.addInitScript(() => {
+ type Frame = { readonly _tag?: string; readonly tag?: string; readonly id?: string | number };
+ const checks: Array<() => Promise<void>> = [];
+ const send = WebSocket.prototype.send;
+ WebSocket.prototype.send = function (this: WebSocket, data) {
+ if (typeof data !== "string") return send.call(this, data);
+ const parsed: Frame | Frame[] = JSON.parse(data);
+ const frames = [parsed].flat();
+ const check = frames.find(
+ (frame) => frame._tag === "Request" && frame.tag === "server.checkSecretSource",
+ );
+ if (!check) return send.call(this, data);
+ const other = frames.filter((frame) => frame !== check);
+ if (other.length > 0) send.call(this, JSON.stringify(other));
+ checks.push(
+ () =>
+ new Promise<void>((resolve) => {
+ const receive = (event: MessageEvent) => {
+ if (typeof event.data !== "string") return;
+ const replies: Array<{ _tag?: string; requestId?: string | number }> = [
+ JSON.parse(event.data),
+ ].flat();
+ if (!replies.some((reply) => reply._tag === "Exit" && reply.requestId === check.id))
+ return;
+ this.removeEventListener("message", receive);
+ resolve();
+ };
+ this.addEventListener("message", receive);
+ send.call(this, JSON.stringify(Array.isArray(parsed) ? [check] : check));
+ }),
+ );
+ };
+ window.secretCheckGate = {
+ count: () => checks.length,
+ finishFirst: () => checks[0]!(),
+ };
+ });
+
+ await t3.open(`/settings/source-control?machine=${encodeURIComponent(environment)}`);
+ await screen.getByRole("button", "Toggle GitHub details", { exact: true }).tap();
+ const input = screen.getByRole("textbox", "GitHub token reference", { exact: true });
+ const check = screen.getByRole("button", "Check GitHub token", { exact: true });
+ const waitForCheck = (count: number) =>
+ browser.evaluate(async (count) => {
+ for (let frame = 0; frame < 120; frame++) {
+ if (window.secretCheckGate?.count() === count) return true;
+ await new Promise<number>((resolve) => requestAnimationFrame(resolve));
+ }
+ return false;
+ }, count);
+ const startCheck = async (count: number) => {
+ await check.tap();
+ if (!(await waitForCheck(count))) throw new Error("The check did not reach the transport");
+ };
+ const commit = async (reference: string) => {
+ await input.fill(reference);
+ await input.press("Enter");
+ };
+
+ await startCheck(1);
+ await commit(REFERENCE_B);
+ await startCheck(2);
+ await commit(REFERENCE_A);
+ await startCheck(3);
+ const pending = await browser.evaluate(async () => {
+ await window.secretCheckGate!.finishFirst();
+ for (let frame = 0; frame < 10; frame++) {
+ await new Promise<number>((resolve) => requestAnimationFrame(resolve));
+ }
+ return (
+ document.querySelector<HTMLButtonElement>('button[aria-label="Check GitHub token"]')
+ ?.disabled === true
+ );
+ });
+ await app.screenshot("new-secret-check-after-old-reply");
+ expect(pending, "The newer secret check is still pending after the earlier reply").toBe(true);
+ },
+);pnpm scenarios:prove scripts/scenarios/secret-check-keeps-new-attempt-pending.e2e.ts --base mainWorkaround
No response
Metadata
Metadata
Assignees
Labels
vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.


Activity