fix: preserve ios bg refresh plist key and handle web login retry failures

This commit is contained in:
Nimrod Gutman
2026-02-20 14:28:31 +02:00
committed by Nimrod Gutman
parent 8775d34fba
commit ac0c1c26b1
3 changed files with 24 additions and 0 deletions

View File

@@ -100,6 +100,8 @@ targets:
UIBackgroundModes:
- audio
- remote-notification
BGTaskSchedulerPermittedIdentifiers:
- ai.openclaw.ios.bgrefresh
NSLocalNetworkUsageDescription: OpenClaw discovers and connects to your OpenClaw gateway on the local network.
NSAppTransportSecurity:
NSAllowsArbitraryLoadsInWebContent: true

View File

@@ -80,6 +80,22 @@ describe("loginWeb coverage", () => {
expect(secondSock.ws.close).toHaveBeenCalled();
});
it("formats retry failure when restart login also closes", async () => {
formatErrorMock.mockReturnValueOnce("status=408 Request Time-out QR refs attempts ended");
waitForWaConnectionMock
.mockRejectedValueOnce({ output: { statusCode: 515 } })
.mockRejectedValueOnce({
output: {
statusCode: 408,
payload: { error: "Request Time-out", message: "QR refs attempts ended" },
},
});
await expect(loginWeb(false, waitForWaConnectionMock as never)).rejects.toThrow(
/status=408 Request Time-out QR refs attempts ended/i,
);
});
it("clears creds and throws when logged out", async () => {
waitForWaConnectionMock.mockRejectedValueOnce({
output: { statusCode: DisconnectReason.loggedOut },

View File

@@ -45,6 +45,12 @@ export async function loginWeb(
await wait(retry);
console.log(success("✅ Linked after restart; web session ready."));
return;
} catch (retryErr) {
const formatted = formatError(retryErr);
console.error(
danger(`WhatsApp Web connection ended after restart before fully opening. ${formatted}`),
);
throw new Error(formatted, { cause: retryErr });
} finally {
setTimeout(() => retry.ws?.close(), 500);
}