v1.2.0:2 — retry login/signup server action once on transport failure

iOS Safari reuses a keep-alive socket the server closed while the login
form sat idle during typing, so the first Sign In / Create account POST
dies instantly with NSURLErrorNetworkConnectionLost ("The network
connection was lost"). That rejects the server-action call, hitting the
client-side catch in LoginForm/SignupForm and showing "An unexpected
error occurred"; the second tap lands on a fresh connection and works.

Add lib/retryAction.ts: retryOnTransportError() retries the action once
only when the call throws. A returned { error } (bad password, rate
limit) is a real result and passes straight through. A lost-on-a-stale-
socket POST never reached the server, so retrying it once is safe.
This commit is contained in:
Keysat
2026-06-15 16:44:33 -05:00
parent 56963ab4fd
commit 0178f8f5cc
6 changed files with 108 additions and 3 deletions
+4 -1
View File
@@ -3,6 +3,7 @@
import { useState } from 'react';
import { useRouter } from 'next/navigation';
import { loginAction } from './actions';
import { retryOnTransportError } from '@/lib/retryAction';
export default function LoginForm() {
const router = useRouter();
@@ -17,7 +18,9 @@ export default function LoginForm() {
setLoading(true);
try {
const result = await loginAction(email, password);
const result = await retryOnTransportError(() =>
loginAction(email, password)
);
if (result.error) {
setError(result.error);