PageSourceSearch

https://www.endurancesoftwares.com/_next/static/chunks/pages/blog/…ent-apps-guide-2026-37869b29edb986464d53.js

js endurancesoftwares.com collected 2026-10-08 04:27:21 UTC 6,789 bytes, 1 lines download raw bytes

1_N_E=(window.webpackJsonp_N_E=window.webpackJsonp_N_E||[]).push([[152],{"TYV/":function(e,r,t){"use strict";t.r(r),t.d(r,"default",(function(){return c}));var n=t("nKUr"),s=t("YFqc"),a=t.n(s),i=t("tOv2");function c(){var e=[{id:"model",nav:"Failure model",title:"Classify failures before choosing the UI",content:Object(n.jsxs)(n.Fragment,{children:[Object(n.jsx)("p",{children:"Not every unsuccessful result is an exception. Validation feedback, missing permissions, and an empty search are expected outcomes; broken dependencies, programmer defects, and corrupted data are operational failures. Give each class a deliberate response."}),Object(n.jsxs)("div",{className:"cards",children:[Object(n.jsxs)("div",{children:[Object(n.jsx)("h3",{children:"Expected"}),Object(n.jsx)("p",{children:"Return typed, actionable feedback beside the user's task."})]}),Object(n.jsxs)("div",{children:[Object(n.jsx)("h3",{children:"Recoverable"}),Object(n.jsx)("p",{children:"Preserve context and offer a safe retry or alternate path."})]}),Object(n.jsxs)("div",{children:[Object(n.jsx)("h3",{children:"Unexpected"}),Object(n.jsx)("p",{children:"Contain the fault, show a stable fallback, and emit diagnostics."})]})]}),Object(n.jsx)("p",{children:"A single generic \u201csomething went wrong\u201d path hides useful product decisions and makes production diagnosis harder."})]})},{id:"boundaries",nav:"Error boundaries",title:"Contain rendering failures near useful recovery points",content:Object(n.jsxs)(n.Fragment,{children:[Object(n.jsx)("p",{children:"Place boundaries around route segments or features that can fail independently. A recommendation panel should not erase checkout; an analytics chart should not blank the entire dashboard. The fallback must explain impact without exposing stack traces, tokens, database details, or private identifiers."}),Object(n.jsxs)("div",{className:"callout",children:[Object(n.jsx)("strong",{children:"Recovery must be real:"})," retry only when the operation is safe and the failed work can actually run again. Otherwise link to a stable route or preserve a draft for later."]})]})},{id:"server",nav:"Server errors",title:"Return stable contracts from server code",content:Object(n.jsxs)(n.Fragment,{children:[Object(n.jsx)("p",{children:"Validate input before effects, authorize the specific resource, and map known domain failures to small response codes. Log the internal cause with a request ID while returning a safe message to the browser."}),Object(n.jsx)("pre",{children:Object(n.jsx)("code",{children:'try {\n  const order = await placeOrder(input, actor);\n  return { ok: true, orderId: order.id };\n} catch (error) {\n  logger.error({ error, requestId }, "order_failed");\n  return { ok: false, code: "ORDER_UNAVAILABLE", requestId };\n}'})}),Object(n.jsx)("p",{children:"Do not catch an error only to discard it. Either translate it at an ownership boundary or let it reach the boundary responsible for reporting and fallback rendering."})]})},{id:"retries",nav:"Retries and side effects",title:"Retry reads carefully and mutations defensively",content:Object(n.jsxs)(n.Fragment,{children:[Object(n.jsx)("p",{children:"Use short timeouts, capped backoff, and jitter for transient dependency failures. Retries amplify outages when every request repeats expensive work, and they can duplicate payments, emails, or orders unless mutations are idempotent."}),Object(n.jsxs)("ul",{children:[Object(n.jsx)("li",{children:"Never retry validation, authorization, or permanent not-found outcomes."}),Object(n.jsx)("li",{children:"Stop retries when the user leaves or the request deadline expires."}),Object(n.jsx)("li",{children:"Show cached or partial data only when its age and limitations are acceptable."}),Object(n.jsx)("li",{children:"Provide a reconciliation path for uncertain side effects."})]}),Object(n.jsxs)("p",{children:["For mutation protections, use the validation and authorization practices in our ",Object(n.jsx)(a.a,{href:"/blog/nextjs-server-actions-security-guide-2026",children:Object(n.jsx)("a",{children:"Server Actions security guide"})}),"."]})]})},{id:"observe",nav:"Observability",title:"Make every incident traceable without leaking data",content:Object(n.jsxs)(n.Fragment,{children:[Object(n.jsx)("p",{children:"Attach a stable request ID to the browser response, server logs, downstream calls, and user support message. Record route template, operation, outcome, latency, dependency, and deployment version with bounded labels. Sample noisy successes, but retain enough failure context to reproduce the sequence."}),Object(n.jsxs)("p",{children:["Alert on user impact\u2014failed checkouts, error-boundary views, sustained route failure, or latency\u2014not every logged exception. Connect these signals using our ",Object(n.jsx)(a.a,{href:"/blog/nextjs-observability-request-tracing-logging-guide-2026",children:Object(n.jsx)("a",{children:"request tracing and alerting guide"})}),"."]})]})},{id:"checklist",nav:"Checklist",title:"Next.js error handling checklist",content:Object(n.jsxs)("div",{className:"checklist",children:[Object(n.jsx)("p",{children:"\u2713 Expected outcomes use typed feedback"}),Object(n.jsx)("p",{children:"\u2713 Boundaries preserve unaffected features"}),Object(n.jsx)("p",{children:"\u2713 Errors never expose sensitive details"}
1),Object(n.jsx)("p",{children:"\u2713 Server responses use stable codes"}),Object(n.jsx)("p",{children:"\u2713 Retries are capped and cancellable"}),Object(n.jsx)("p",{children:"\u2713 Mutations are safe against duplicates"}),Object(n.jsx)("p",{children:"\u2713 Request IDs join client and server evidence"}),Object(n.jsx)("p",{children:"\u2713 Alerts measure real user impact"})]})}];return Object(n.jsx)(i.a,{title:"Next.js Error Handling: Build Resilient Production Apps",description:"Handle Next.js failures with clear error classes, useful boundaries, safe server contracts, controlled retries, request tracing, and recovery-focused user experiences.",slug:"nextjs-error-handling-resilient-apps-guide-2026",image:"/img/blog-covers/nextjs-error-handling-resilient-apps-guide-2026.png",imageAlt:"A web application containing one failure while healthy sections remain available",eyebrow:"Next.js reliability",lead:"Failures are inevitable; blank screens and mysterious support tickets are not. Design boundaries that contain damage, preserve user context, and leave enough evidence for a fast diagnosis.",keywords:"Next.js error handling, error boundaries, resilient web apps, Next.js production, retry strategy, observability",accent:"rgba(16,185,129,.3)",sections:e})}},iq4A:function(e,r,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/blog/nextjs-error-handling-resilient-apps-guide-2026",function(){return t("TYV/")}])}},[["iq4A",0,2,1,3,4,5,6,7,8,24]]]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.