Episode 2 — React Frontend Architecture NextJS / 2.21 — Working with Server Actions
2.21.c — Implementing Mutations & Forms
In one sentence: You implement Server Actions as ordinary async functions that perform side effects, then wire them to the UI through
formactions,bindfor extra arguments, and cache revalidation so users see fresh data.
Navigation: ← The use server Directive · Next → Security, Errors & Production
1. Minimal Server Action + Form (Server Component)
// app/signup/page.tsx — Server Component (no 'use client')
import { createAccount } from './actions';
export default function SignupPage() {
return (
<form action={createAccount}>
<label>
Email
<input name="email" type="email" required />
</label>
<label>
Password
<input name="password" type="password" required minLength={8} />
</label>
<button type="submit">Create account</button>
</form>
);
}
// app/signup/actions.ts
'use server';
import { redirect } from 'next/navigation';
export async function createAccount(formData: FormData) {
const email = String(formData.get('email') ?? '');
const password = String(formData.get('password') ?? '');
if (!email.includes('@')) {
// Prefer structured error return for forms — see §3
throw new Error('Invalid email');
}
// await db.insert(...)
redirect('/dashboard');
}
What happens:
- User submits the form — browser performs a navigation-style POST handled by Next.js.
- The action runs on the server with the
FormData. redirect()throws a special internal error that becomes an HTTP redirect response.
2. Passing Extra Arguments: bind
HTML forms only post fields. If you need a resource id that should not be editable in the DOM, use Function.prototype.bind:
// Server or Client Component usage pattern
<form action={updatePost.bind(null, post.id)}>
<input name="title" defaultValue={post.title} />
<button type="submit">Save</button>
</form>
'use server';
export async function updatePost(id: string, formData: FormData) {
const title = String(formData.get('title') ?? '');
// await db.post.update({ where: { id }, data: { title } })
}
Why this matters in interviews: It shows you understand which data is trusted (nothing from the client is trusted) — you still re-fetch the row on the server and verify ownership before updating.
3. Returning Validation Errors (Preferred over Throwing)
For expected validation failures, return a serializable object instead of throwing — the UI can render inline errors without treating it as a crash.
'use server';
type FieldErrors = { email?: string; password?: string };
export type SignupState =
| { ok: true }
| { ok: false; fieldErrors: FieldErrors };
export async function createAccountWithState(
_prev: SignupState,
formData: FormData,
): Promise<SignupState> {
const email = String(formData.get('email') ?? '');
const password = String(formData.get('password') ?? '');
const fieldErrors: FieldErrors = {};
if (!email.includes('@')) fieldErrors.email = 'Invalid email';
if (password.length < 8) fieldErrors.password = 'Too short';
if (Object.keys(fieldErrors).length) {
return { ok: false, fieldErrors };
}
// await persistUser(...)
return { ok: true };
}
Wiring with useActionState (React 19)
'use client';
import { useActionState } from 'react';
import { createAccountWithState, type SignupState } from './actions';
const initialState: SignupState = { ok: false, fieldErrors: {} };
export function SignupForm() {
const [state, formAction, isPending] = useActionState(createAccountWithState, initialState);
return (
<form action={formAction}>
<label>
Email
<input name="email" />
{state.ok === false && state.fieldErrors.email && (
<p role="alert">{state.fieldErrors.email}</p>
)}
</label>
{/* ... */}
<button type="submit" disabled={isPending}>
{isPending ? 'Saving…' : 'Create account'}
</button>
</form>
);
}
Note: In older material you may see useFormState — in React 19 the canonical hook is useActionState. Same idea: the action receives the previous state as its first argument when used through this hook.
4. Pending UI: useFormStatus
For submit button pending state inside a child of the form, React provides useFormStatus:
'use client';
import { useFormStatus } from 'react-dom';
export function SubmitButton({ label }: { label: string }) {
const { pending } = useFormStatus();
return (
<button type="submit" disabled={pending}>
{pending ? 'Working…' : label}
</button>
);
}
Why not only useActionState’s isPending? Button components are often factored out; useFormStatus reads the nearest <form> submission state without prop drilling.
5. Showing Fresh Data: revalidatePath and revalidateTag
After a mutation, cached Server Component output may be stale.
'use server';
import { revalidatePath, revalidateTag } from 'next/cache';
export async function addComment(formData: FormData) {
// await db.comment.create(...)
revalidatePath('/posts/[slug]', 'page'); // example intent — adjust to your route segment config
// or: revalidateTag('posts');
}
Interview talking points:
revalidatePath— coarse, path-oriented; great when you know exactly which pages change.revalidateTag— pairs withfetch(..., { next: { tags: ['posts'] } })orunstable_cachetags for finer cache control.
6. Imperative Invocation: useTransition
Not every mutation comes from a <form>. You can call an action from event handlers:
'use client';
import { useTransition } from 'react';
import { archiveProject } from './actions';
export function ArchiveButton({ projectId }: { projectId: string }) {
const [isPending, startTransition] = useTransition();
return (
<button
type="button"
disabled={isPending}
onClick={() => {
startTransition(() => {
void archiveProject(projectId);
});
}}
>
Archive
</button>
);
}
'use server';
export async function archiveProject(projectId: string) {
// verify auth + ownership, then update
}
Trade-off: This path is ergonomic but easy to overuse for non-idempotent operations without optimistic UX — pair with loading states and error toasts.
7. Composition: Keep Actions Thin
Good structure:
actions.ts → parse/validate input, call services, revalidate
services/user.ts → business rules + DB
lib/auth.ts → session helpers
Thin action:
'use server';
import { z } from 'zod';
import { createUser as createUserService } from '@/services/users';
const schema = z.object({
email: z.string().email(),
name: z.string().min(1),
});
export async function createUser(formData: FormData) {
const parsed = schema.safeParse({
email: formData.get('email'),
name: formData.get('name'),
});
if (!parsed.success) {
return { ok: false as const, errors: parsed.error.flatten().fieldErrors };
}
await createUserService(parsed.data);
return { ok: true as const };
}
This mirrors how Express handlers should delegate to a service layer — same architecture, different transport.
8. Progressive Enhancement (What to Say in Interviews)
A plain <form action={serverAction}> does not require client JavaScript to attempt the mutation — the browser knows how to submit forms.
Caveat: The moment you need rich client validation, multi-step wizards, or useActionState, you introduce a Client Component and raise the JS requirement for that UX tier. Interviewers like hearing that you know the difference between baseline HTML behavior and enhanced behavior.
9. Checklist Before You Ship a Mutation
| Step | Question |
|---|---|
| Authn | Do I know who is calling this? |
| Authz | May this principal perform this operation on this resource? |
| Validation | Do I reject bad input on the server (never trust the client)? |
| Idempotency | What happens if the user double-clicks submit? |
| UX | Do I show pending and error states? |
| Cache | Do I revalidate the right segments/tags? |
Next: 2.21.d — Security, Errors & Production
Part 2 — Deep Encyclopedia (Mutations & forms)
How to use this section: Read sequentially or jump by drill number. Each block has a scenario, a prompt (what an interviewer might ask), a model answer, and often a code sketch.
E001 — SA drill 1: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 1: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #1.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #1, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E002 — SA drill 2: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 2: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #2.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #2, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E003 — SA drill 3: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 3: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #3.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #3, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E004 — SA drill 4: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 4: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #4.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #4, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E005 — SA drill 5: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 5: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #5.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #5, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E006 — SA drill 6: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 6: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #6.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #6, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E007 — SA drill 7: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 7: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #7.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #7, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E008 — SA drill 8: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 8: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #8.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #8, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E009 — SA drill 9: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 9: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #9.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #9, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E010 — SA drill 10: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 10: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #10.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #10, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E011 — SA drill 11: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 11: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #11.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #11, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E012 — SA drill 12: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 12: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #12.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #12, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E013 — SA drill 13: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 13: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #13.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #13, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E014 — SA drill 14: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 14: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #14.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #14, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E015 — SA drill 15: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 15: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #15.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #15, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E016 — SA drill 16: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 16: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #16.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #16, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E017 — SA drill 17: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 17: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #17.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #17, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E018 — SA drill 18: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 18: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #18.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #18, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E019 — SA drill 19: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 19: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #19.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #19, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E020 — SA drill 20: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 20: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #20.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #20, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E021 — SA drill 21: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 21: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #21.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #21, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E022 — SA drill 22: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 22: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #22.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #22, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E023 — SA drill 23: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 23: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #23.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #23, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E024 — SA drill 24: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 24: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #24.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #24, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E025 — SA drill 25: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 25: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #25.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #25, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E026 — SA drill 26: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 26: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #26.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #26, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E027 — SA drill 27: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 27: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #27.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #27, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E028 — SA drill 28: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 28: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #28.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #28, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E029 — SA drill 29: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 29: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #29.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #29, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E030 — SA drill 30: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 30: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #30.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #30, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E031 — SA drill 31: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 31: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #31.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #31, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E032 — SA drill 32: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 32: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #32.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #32, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E033 — SA drill 33: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 33: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #33.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #33, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E034 — SA drill 34: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 34: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #34.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #34, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E035 — SA drill 35: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 35: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #35.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #35, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E036 — SA drill 36: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 36: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #36.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #36, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E037 — SA drill 37: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 37: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #37.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #37, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E038 — SA drill 38: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 38: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #38.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #38, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E039 — SA drill 39: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 39: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #39.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #39, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E040 — SA drill 40: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 40: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #40.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #40, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E041 — SA drill 41: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 41: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #41.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #41, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E042 — SA drill 42: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 42: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #42.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #42, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E043 — SA drill 43: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 43: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #43.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #43, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E044 — SA drill 44: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 44: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #44.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #44, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E045 — SA drill 45: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 45: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #45.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #45, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E046 — SA drill 46: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 46: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #46.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #46, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E047 — SA drill 47: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 47: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #47.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #47, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E048 — SA drill 48: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 48: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #48.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #48, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E049 — SA drill 49: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 49: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #49.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #49, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E050 — SA drill 50: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 50: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #50.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #50, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E051 — SA drill 51: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 51: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #51.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #51, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E052 — SA drill 52: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 52: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #52.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #52, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E053 — SA drill 53: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 53: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #53.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #53, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E054 — SA drill 54: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 54: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #54.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #54, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E055 — SA drill 55: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 55: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #55.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #55, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E056 — SA drill 56: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 56: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #56.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #56, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E057 — SA drill 57: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 57: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #57.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #57, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E058 — SA drill 58: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 58: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #58.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #58, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E059 — SA drill 59: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 59: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #59.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #59, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E060 — SA drill 60: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 60: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #60.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #60, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E061 — SA drill 61: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 61: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #61.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #61, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E062 — SA drill 62: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 62: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #62.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #62, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E063 — SA drill 63: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 63: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #63.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #63, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E064 — SA drill 64: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 64: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #64.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #64, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E065 — SA drill 65: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 65: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #65.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #65, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E066 — SA drill 66: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 66: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #66.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #66, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E067 — SA drill 67: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 67: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #67.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #67, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E068 — SA drill 68: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 68: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #68.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #68, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E069 — SA drill 69: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 69: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #69.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #69, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E070 — SA drill 70: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 70: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #70.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #70, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E071 — SA drill 71: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 71: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #71.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #71, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E072 — SA drill 72: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 72: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #72.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #72, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E073 — SA drill 73: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 73: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #73.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #73, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E074 — SA drill 74: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 74: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #74.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #74, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E075 — SA drill 75: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 75: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #75.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #75, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E076 — SA drill 76: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 76: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #76.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #76, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E077 — SA drill 77: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 77: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #77.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #77, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E078 — SA drill 78: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 78: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #78.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #78, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E079 — SA drill 79: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 79: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #79.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #79, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E080 — SA drill 80: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 80: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #80.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #80, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E081 — SA drill 81: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 81: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #81.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #81, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E082 — SA drill 82: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 82: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #82.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #82, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E083 — SA drill 83: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 83: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #83.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #83, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E084 — SA drill 84: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 84: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #84.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #84, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E085 — SA drill 85: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 85: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #85.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #85, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E086 — SA drill 86: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 86: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #86.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #86, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E087 — SA drill 87: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 87: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #87.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #87, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E088 — SA drill 88: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 88: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #88.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #88, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E089 — SA drill 89: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 89: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #89.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #89, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E090 — SA drill 90: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 90: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #90.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #90, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E091 — SA drill 91: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 91: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #91.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #91, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E092 — SA drill 92: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 92: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #92.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #92, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E093 — SA drill 93: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 93: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #93.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #93, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E094 — SA drill 94: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 94: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #94.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #94, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E095 — SA drill 95: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 95: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #95.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #95, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E096 — SA drill 96: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 96: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #96.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #96, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E097 — SA drill 97: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 97: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #97.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #97, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E098 — SA drill 98: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 98: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #98.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #98, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E099 — SA drill 99: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 99: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #99.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #99, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E100 — SA drill 100: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 100: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #100.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #100, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E101 — SA drill 101: Double-submit: user clicks Save twice rapidly.
Scenario: Double-submit: user clicks Save twice rapidly. (variation 101: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #101.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #101, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E102 — SA drill 102: Optimistic UI then server rejects
Scenario: Optimistic UI then server rejects — rollback strategy. (variation 102: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #102.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #102, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E103 — SA drill 103: Passing class instances as action arguments by mistake.
Scenario: Passing class instances as action arguments by mistake. (variation 103: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #103.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #103, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E104 — SA drill 104: File upload via Server Action size limits.
Scenario: File upload via Server Action size limits. (variation 104: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #104.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #104, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E105 — SA drill 105: Calling action inside useEffect infinite loop footgun.
Scenario: Calling action inside useEffect infinite loop footgun. (variation 105: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #105.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #105, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E106 — SA drill 106: Server Action + external redirect open redirect vulnerability.
Scenario: Server Action + external redirect open redirect vulnerability. (variation 106: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #106.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #106, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E107 — SA drill 107: Mixing use server in shared util imported by client.
Scenario: Mixing use server in shared util imported by client. (variation 107: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #107.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #107, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E108 — SA drill 108: Testing actions with mocked headers() cookies.
Scenario: Testing actions with mocked headers() cookies. (variation 108: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #108.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #108, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E109 — SA drill 109: Internationalization error messages from Zod in action.
Scenario: Internationalization error messages from Zod in action. (variation 109: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #109.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #109, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}
E110 — SA drill 110: Batching multiple mutations in one transition.
Scenario: Batching multiple mutations in one transition. (variation 110: consider deployment on a serverless platform with regional databases.)
Prompt: Explain trade-offs and what you would measure (latency, error rate, cost) before/after a change for case #110.
Model answer: Start by naming the user-visible symptom (SEO, staleness, TTFB, consistency). List hypotheses (N+1 queries, blocking waterfall, wrong cache directive, missing revalidation). Propose one smallest experiment: add logging/timing, reduce sequential awaits, adjust revalidate window, or move work to background job. Define rollback. For #110, emphasize that measurement beats opinions: compare p50/p95 TTFB and conversion where relevant.
'use server';
export async function save(prev: unknown, formData: FormData) {
// validate, idempotent write keyed by client intent
return { ok: true as const };
}