



















@@ -72,19 +72,33 @@ async function writeWorkspacePlugin(params: {
7272}
73737474async function readCounterWithRetry(filePath: string): Promise<number> {
75-for (let attempt = 0; attempt < 20; attempt += 1) {
76-try {
77-const raw = await fs.readFile(filePath, "utf8");
78-const parsed = Number.parseInt(raw.trim(), 10);
79-if (Number.isFinite(parsed)) {
80-return parsed;
81-}
82-} catch {
83-// Wait briefly for gateway startup to finish plugin registration.
84-}
85-await new Promise((resolve) => setTimeout(resolve, 50));
75+let counter: number | undefined;
76+try {
77+await expect
78+.poll(
79+async () => {
80+try {
81+const raw = await fs.readFile(filePath, "utf8");
82+const parsed = Number.parseInt(raw.trim(), 10);
83+if (Number.isFinite(parsed)) {
84+counter = parsed;
85+return true;
86+}
87+} catch {
88+// Wait briefly for gateway startup to finish plugin registration.
89+}
90+return false;
91+},
92+{ timeout: 1_000, interval: 50 },
93+)
94+.toBe(true);
95+} catch {
96+throw new Error(`timed out waiting for counter file: ${filePath}`);
97+}
98+if (counter === undefined) {
99+throw new Error(`timed out waiting for counter file: ${filePath}`);
86100}
87-throw new Error(`timed out waiting for counter file: ${filePath}`);
101+return counter;
88102}
8910390104async function setupGatewayTempHome(params: { prefix: string; minimalGateway?: boolean }) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。