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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user