Vue / Advanced: architecture, hydration, and production evidence / Lesson 18
Reliable features, observability, and release decisions
Connect failures and user outcomes to bounded diagnostics and verified release behavior.
On this page
Lesson goals
- Design an honest failure and retry experience.
- Observe bounded outcomes without collecting private payloads.
Define the user-visible success and failure states
A reliable notes feature distinguishes local input, pending work, confirmed outcome, recoverable failure, and invalidated work. Error handling should preserve useful user effort and offer a deliberate next action. A generic spinner that never ends or a success banner before server acceptance can mislead users. Decide which operations can be retried safely and which need an idempotency or reconciliation contract. Keep route changes, account changes, and component disposal in the scenario set. Reliability is a behavior of the assembled feature, not merely a component that renders without a console error.
Provide a controlled rendering failure boundary
onErrorCaptured can observe errors from descendant components under Vue’s documented rules. The boundary below replaces its child content with a fallback and returns false to stop further propagation for this intentionally handled case. That choice can also prevent application-level error handling, so design reporting and policy deliberately rather than suppressing unknown failures silently. The boundary must not render the same failing child again while showing the fallback. It does not automatically catch every asynchronous service error or browser event outside Vue’s handling; model those at their relevant boundaries.
<script setup>
import { ref, onErrorCaptured } from "vue"
const failed = ref(false)
onErrorCaptured(() => {
failed.value = true
return false
})
</script>
<template>
<p v-if="failed" role="alert">This section could not be displayed.</p>
<slot v-else />
</template>
Requires child content supplied through the slot in a compatible Vue app. It intentionally handles propagation and contains no telemetry transport. The fallback behavior and error hooks were not runtime-tested in the authoring environment.
Measure outcomes with a bounded event schema
Useful diagnostics identify feature, operation category, release, timing, and an opaque correlation reference where needed. Avoid titles, note bodies, credentials, full URLs, and raw error objects unless a reviewed collection policy justifies specific fields. Logs and browser traces can expose more than a developer expects. Keep metrics dimensions bounded and preserve detailed investigation links under access and retention controls. A missing event stream is not proof of zero failures. Define how evidence is collected, sampled, and checked so the next maintainer can distinguish product failure, stale work, environment failure, and missing diagnostics.
Validate a safe synthetic telemetry shape
The complete function accepts only a bounded result category and finite nonnegative duration. It converts duration into a coarse bucket and returns no user content. This demonstrates data minimization, not a full telemetry pipeline. A real implementation must define consent where applicable, retention, transport, sampling, integrity, and release association. Do not add private payloads to the object merely to make debugging easier. The standalone assertion checks the exact local schema, while a production integration test would verify the configured collection path without publishing secrets or sending uncontrolled traffic.
function operationSummary({ result, durationMs }) {
const allowed = new Set(["success", "failure", "cancelled"])
if (!allowed.has(result) || !Number.isFinite(durationMs) || durationMs < 0) {
throw new Error("INVALID_OPERATION_METRIC")
}
return { result, durationBucket: durationMs < 1000 ? "under-1s" : "at-least-1s" }
}
const event = operationSummary({ result: "success", durationMs: 250 })
if (JSON.stringify(event) !== JSON.stringify({ result: "success", durationBucket: "under-1s" })) {
throw new Error("METRIC_SCHEMA_MISMATCH")
}
Runs under Node with synthetic values only. It sends no event and reads no browser or project data. The one-second boundary is a teaching bucket, not a universal performance requirement.
Review the exact release candidate and recovery limits
Validate the production artifact under the intended browser, route, locale, accessibility, data, and SSR assumptions. Keep source revision, dependency versions, build configuration, and test evidence connected. A green unit suite does not prove direct-route hosting, chunk loading, state hydration, or account isolation. Release monitoring should have an owner and an actionable response to regression, with a recovery plan that considers data and compatibility. Do not assume an older client bundle can safely read every new server response after rollback. The course performs no publication or deployment; its release examples describe evidence and ownership rather than authorizing external actions.
Common errors and fixes
A rendering boundary silently hides every error
- Why it happens
- Propagation control is used without reporting and recovery policy.
- How to fix it
- Define handled cases, fallback, diagnostics, and escalation deliberately.
- Prevent it next time
- Test boundary and application-level error interactions.
Diagnostic events contain private note content
- Why it happens
- Raw payloads are collected instead of bounded outcomes.
- How to fix it
- Minimize fields and follow the data owner’s exposure process.
- Prevent it next time
- Review schemas and traces before enabling collection.
A rollback restores code but breaks state compatibility
- Why it happens
- Client/server and persisted-state contracts were omitted.
- How to fix it
- Use the reviewed compatible recovery path and validate user tasks.
- Prevent it next time
- Plan recovery with release and data evolution.
Check your understanding
1. A component boundary shows a fallback. Does that resolve an API write failure?
Show worked solution
No. Rendering failure and remote operation state have different boundaries. Preserve the draft and ambiguous write outcome, apply the service’s retry/idempotency policy, and expose an honest user action. The boundary is one part of the feature’s recovery design.
2. Monitoring reports no failures after the event collector stops. What should the release owner conclude?
Show worked solution
The evidence is incomplete. Verify collection health and the affected observation window rather than declaring the release healthy from missing data. Use other authorized signals and keep uncertainty visible until the evidence path is restored.
Key takeaways
- Reliable UX separates pending, confirmed, failed, and obsolete work.
- Diagnostics should be bounded and privacy-conscious.
- Release confidence depends on the exact artifact and recovery contract.