
























@@ -470,6 +470,10 @@ function messageMatches(message: WhatsAppObservedMessage, matchText: string | Re
470470 : matchText.test(message.text);
471471}
472472473+function isTransientWhatsAppQaDriverError(error: unknown) {
474+return /\bConnection Closed\b/iu.test(formatErrorMessage(error));
475+}
476+473477async function runWhatsAppScenario(params: {
474478driver: WhatsAppQaDriverSession;
475479driverPhoneE164: string;
@@ -754,7 +758,7 @@ export async function runWhatsAppQaLive(params: {
754758parentDir: tempAuthRoot,
755759}),
756760]);
757-const activeDriver = await startWhatsAppQaDriverSession({ authDir: driverAuthDir });
761+let activeDriver = await startWhatsAppQaDriverSession({ authDir: driverAuthDir });
758762driver = activeDriver;
759763760764for (const scenario of scenarios) {
@@ -768,32 +772,50 @@ export async function runWhatsAppQaLive(params: {
768772);
769773continue;
770774}
771-try {
772-const result = await runWhatsAppScenario({
773-driver: activeDriver,
774-driverPhoneE164: runtimeEnv.driverPhoneE164,
775- gatewayDebugDirPath,
776- observedMessages,
777- providerMode,
778- primaryModel,
779- alternateModel,
780-fastMode: params.fastMode,
781-groupJid: runtimeEnv.groupJid,
782- repoRoot,
783- scenario,
784- sutAccountId,
785- sutAuthDir,
786-sutPhoneE164: runtimeEnv.sutPhoneE164,
787-});
788-scenarioResults.push(result);
789-} catch (error) {
790-preservedGatewayDebugArtifacts = true;
791-scenarioResults.push({
792-id: scenario.id,
793-title: scenario.title,
794-status: "fail",
795-details: formatErrorMessage(error),
796-});
775+let retriedDriver = false;
776+while (true) {
777+try {
778+const result = await runWhatsAppScenario({
779+driver: activeDriver,
780+driverPhoneE164: runtimeEnv.driverPhoneE164,
781+ gatewayDebugDirPath,
782+ observedMessages,
783+ providerMode,
784+ primaryModel,
785+ alternateModel,
786+fastMode: params.fastMode,
787+groupJid: runtimeEnv.groupJid,
788+ repoRoot,
789+ scenario,
790+ sutAccountId,
791+ sutAuthDir,
792+sutPhoneE164: runtimeEnv.sutPhoneE164,
793+});
794+scenarioResults.push(
795+retriedDriver
796+ ? { ...result, details: `${result.details}; driver reconnected` }
797+ : result,
798+);
799+break;
800+} catch (error) {
801+if (!retriedDriver && isTransientWhatsAppQaDriverError(error)) {
802+retriedDriver = true;
803+await activeDriver.close().catch(() => {});
804+activeDriver = await startWhatsAppQaDriverSession({ authDir: driverAuthDir });
805+driver = activeDriver;
806+continue;
807+}
808+preservedGatewayDebugArtifacts = true;
809+scenarioResults.push({
810+id: scenario.id,
811+title: scenario.title,
812+status: "fail",
813+details: formatErrorMessage(error),
814+});
815+break;
816+}
817+}
818+if (scenarioResults.at(-1)?.status === "fail") {
797819break;
798820}
799821}
@@ -921,6 +943,7 @@ export const __testing = {
921943 buildWhatsAppQaConfig,
922944 createMissingGroupJidScenarioResult,
923945 findScenarios,
946+ isTransientWhatsAppQaDriverError,
924947 parseWhatsAppQaCredentialPayload,
925948 resolveWhatsAppQaRuntimeEnv,
926949 resolveWhatsAppMetadataRedaction,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。