Skip to Content
ArchitectureFailure & Degradation

Failure & degradation

What happens when a dependency or a stage fails: whether the error is caught or propagates, what the caller or the task gets, what has already happened by then, and whether the code retries or falls back. A successful response, a committed row, a published message and a finished worker job are separate outcomes; this page keeps them apart. How a thrown value becomes a response body is on Request lifecycle: error handling; what stops a whole process is on Process lifecycle. Terms are in the Glossary.

Request lifecycle · API error variants · Repliers proxy · Persistence · Follow Up Boss outcomes · Troubleshooting

Failure outcomes

One row per stage or dependency. “Variant” refers to the five branches of the error handler (error variants): 1 is ApiError, 5 is the generic 500.

Stage / dependencyCatch / propagationHTTP / task resultCompleted side effectsRetry / fallback implementedSource
Request validation (Joi)Handler throws ApiError(error.message, 400)400, variant 1none; the service is not callednoneroute files, src/validate/*.ts
Authentication (koa-jwt, revocation lookup)Strict: koa HttpError; passthrough: ApiError (verifying)401, variant 2 or 1nonenonesrc/providers/middleware/jwt/*.ts
Repliers, error responseRepliersBase.request rethrows ApiError("Repliers API error: <status>", <status>, <response body>)the upstream status relayed, the upstream body in info, variant 1awaited writes earlier in the same request staynonesrc/services/repliers/base.ts (request)
Repliers, no response (timeout REPLIERS_TIMEOUT, connection error)same wrapper, with status undefined500, message undefined - Repliers API error: undefined - <path> (observed)as abovenonesrc/services/repliers/base.ts (request)
Repliers throttlep-throttle queues the call; nothing is rejectednone by itself; the wait adds to the response timenonethe queue is the only control; see Retry layerssrc/providers/throttler/repliers.ts, repliersWarmup.ts
Mapbox or Google Maps, error responseApiError("Mapbox API error") / ApiError("Google API error") with the provider status and bodyprovider status, variant 1nonenonesrc/services/mapbox.ts, src/services/google.ts (request)
Mapbox or Google Maps, no responsethe .catch reads e.response.status with no response, which throws a TypeError500, variant 5: Internal Server Error, plus err, stack and file outside production (observed)nonenonesrc/services/mapbox.ts, src/services/google.ts (request)
Google Maps status other than OK / ZERO_RESULTSa plain Error thrown from googleAddress500, variant 5noneZERO_RESULTS gives []src/services/autosuggest.ts (googleAddress)
Autosuggest branchesPromise.all; only the MLS-number branch has a .catch (branch register)a failed Mapbox, listings or locations branch fails the request with that branch’s errorthe other branches’ upstream calls still completeMLS-number branch: logged at debug level, yields null, the primary listings are returned alonesrc/services/autosuggest.ts (search)
Mapbox address that the parser rejectsparseAddressSafe returns {}200; parts filled from the Mapbox contextnoneparser fallbacksrc/services/autosuggest.ts (parseAddressSafe)
Google prediction that the parser rejectsper-prediction try200; that prediction is droppednonedropsrc/services/autosuggest.ts (googleAddress)
Estimate enrichment (neighborhood, tax adjustment, average tax)each step catches, logs at debug level and continues200 with the step’s value missing or unchanged (pipeline)nonethe unenriched valuesrc/services/estimate.ts (getAddressData, adjustPropertyTax, getAverageTax)
Follow Up Boss, from a request pathBossService.request rethrows ApiError("Boss API error", <FUB status>, <FUB body>)FUB status, or 500 without a response, variant 1earlier awaited writes stayBOSS_ENABLED=false: every call returns {} without a requestsrc/services/boss.ts (request)
Follow Up Boss, engagement report after the response.catch in the second handler and in EventsCollectionService (engagement register)none: the response was already decidedthe primary handler’s worknone; the event is lostsrc/providers/middleware/eventsCollection.ts, src/services/eventsCollection/eventsCollection.ts
Event selector property lookupgetProperty catchesthe event is still sent, with only mlsNumber and url for the propertynonereduced eventsrc/services/eventsCollection/selectors/baseEventCollectionSelector.ts (getProperty)
Registration event (signup, OAuth)reportClientRegistration catchesnone: sign-up continuesthe Repliers clientnonesrc/services/auth.ts, src/services/oauth.ts (reportClientRegistration)
Agent send-estimate notesecond handler written in the route, try / catch with console.errornone: the response was already decidedthe estimate send of the primary handlernonesrc/routes/agent.ts
Admin agent batch, one agentper-item try / catch200; the failed item’s entry is the error as JSON text, an item without phone or e-mail is the string Phone or email is missingagents created before and after the failed onenonesrc/services/admin.ts (createAgentsBatch, stringifyError)
PostgreSQL (unreachable, query error)knex rejects with a driver error, not an ApiError500, variant 5; connection refused fails at once (observed)every earlier statement: each repository call autocommits except the sync transaction (transaction boundaries)nonesrc/repository/*.ts, src/app.ts
PostgreSQL pool exhaustedknex waits for a free connection500 after knex’s acquire timeout (library default 60 s; nothing in config.db sets it)as abovenonesrc/config.ts (db.pool), knex 3.3.0
Redis-backed Keyv (REDIS_KEYV_ENABLE=true), Redis unreachablethe Redis client keeps reconnecting; get, set and has wait for a connection and nothing sets a timeout. Observed with the installed keyv 5.6.0, @keyv/redis 5.1.6 and a closed port: get and set still pending after 8 s, no exceptionthe request waits: every request with a token (the revocation lookup), every OTP request and every @cached readnoneno fallback to memorysrc/providers/keyv.*.ts, src/lib/decorators/cached.ts, src/repository/blocklist.ts
In-memory Keyv (the default)no dependency to failnonenonen/a: state is per process and lost on restart (Caching)src/lib/decorators/cached.ts
SMTP send (contact-form messages when SMTP_ENABLED=true and REPLIERS_AGENT_EMAIL are set)the nodemailer rejection propagates500, variant 5nonenone; with SMTP off the same messages go through the Repliers messages API, chosen before the send, not after a failure (feature dependencies)src/services/contact.ts, src/services/smtp.ts (send)
FUB webhook handler: FUB read, row insert, publishawaited in order; any error propagates (handler steps)FUB status or 500 to FUBrows inserted and messages published before the errornone in the backend; FUB’s own redelivery is upstream behaviour, unverifiedsrc/services/boss/webhook.ts (handlePeopleUpdated, handlePeopleCreated, handlePeopleDeleted)
Agent people sync: publish after committhe publish loop runs after the commit; an error propagates500the sync and people_sync rows, and every message published before the errornone; nothing re-publishes a PENDING rowsrc/services/agent.ts (syncBossPeople), src/services/sync.ts (publishUpsert)
NATS disabled (DummyNats)publish resolves with nothing stored204 / { synced } as usualjob rows stay PENDING; no worker runsn/asrc/lib/dummy.nats.ts
Worker job (Repliers, FUB, database)caught in processUpsert / processPeopleUpsert / processPeopleDelete: status written, error rethrown; StreamWorker.process catches ittask status = the error text; message nak (outcomes)Repliers client and FUB AVM-field writes made before the errorredelivery by the NATS server after nak or ack wait (server defaults, unverified)src/services/sync.ts, src/services/boss/webhook.ts (catchProcessingError), src/streams/worker.ts
Worker message that is not valid JSONmessage.json() throws in the handler, before any status writenak; the row keeps its statusnoneredelivery as abovesrc/streams/boss/people.ts, src/streams/worker.ts
Worker message on an unknown subjectno entry in eventMaptermnonenonesrc/streams/worker.ts (process)
Startup (configuration, keys, port, NATS, webhook install)not caughtthe process exits (what stops a step)for the webhook install: old webhooks deleted, some new ones createdworker NATS connect only, and it re-awaits one cached promisesrc/index.ts, src/worker.ts

Retry layers

Every timeout, throttle and retry the code configures, layer by layer. Where the code sets nothing, the library default applies and is named as such. No outbound HTTP call is retried.

LayerTimeoutThrottle / queueRetrySource
Repliers HTTPREPLIERS_TIMEOUT, default 30000 ms, per call (axios); it starts when the throttled call runs, so time in the queue is not countedthrottler:repliers: REPLIERS_API_LIMIT per REPLIERS_API_INTERVAL_MS, process-wide; SSG traffic on throttler:repliers:warmup once a warmup key is set. The queue has no size limit, and the onDelay hook is an empty function, so a wait is not loggednonesrc/services/repliers/base.ts (createAxios, activeThrottler), src/providers/throttler/*.ts
MapboxMAPBOX_TIMEOUT, default 30000 msnonenonesrc/services/mapbox.ts
Google MapsGOOGLE_MAPS_TIMEOUT_MS, default 30000 msnonenonesrc/services/google.ts
Follow Up BossBOSS_TIMEOUT_MS, default 30000 msnonenonesrc/services/boss.ts
SMTPnone set (nodemailer defaults)nonenonesrc/services/smtp.ts
PostgreSQLnone set: knex acquire timeout 60 s (library default), no statement timeoutpool min: 1, max: 5 per processnonesrc/config.ts (db), src/providers/db.ts
Redis (Keyv)none setnonethe Redis client reconnects with the backoff @keyv/redis installs (min(2^attempt × 100, 2000) ms plus jitter, no attempt limit); operations wait meanwhilesrc/providers/keyv.*.ts, src/lib/decorators/cached.ts; @keyv/redis 5.1.6
NATS connectionclient library defaults (reconnect on, 10 attempts, 2 s apart)noneworker start: pRetry (10 retries, exponential from 1 s) around one cached promise, so no second connection; provider: pRetry(() => jetstream(nc)), a constructor that does no I/Osrc/worker.ts, src/providers/nats.ts
NATS publishJetStream API timeout, library default 5 seach publish awaited before the nextnonesrc/services/boss/webhook.ts, src/services/sync.ts; @nats-io/jetstream 3.4.0
Worker messagenone; working() once at the startone message at a time per processnak with no delay, redelivered by the server; term for an unknown subjectsrc/streams/worker.ts
Worker consume loopnonenoneconsume() called again at once after an iteration errorsrc/worker.ts
Inbound HTTPnone set in src/index.ts; Node’s defaults bound only the time to receive a request (requestTimeout 300 s, headersTimeout 60 s), not the handlerrate-limit /api/auth/* in front of the backend (limits)nonesrc/index.ts

The estimate pipeline’s second historical-listings request is a fallback with another key, not a retry of a failed call (pipeline).

Variation

  • Production vs other environments. Variant 5 adds err, stack and file to the body when NODE_ENV is not production (src/app.ts); NODE_ENV unset counts as production (src/config.ts, env).
  • BOSS_ENABLED=false. FUB calls return {}; request paths that read a field of the result then fail or find nothing, and the webhook route answers 500 for created and updated events (variation).
  • NATS_ENABLED=false. Publishing succeeds without storing anything; see the DummyNats row.
  • REDIS_KEYV_ENABLE unset. No Redis dependency, and therefore no Redis failure mode; the stores are per process.

Evidence

  • Source: the files in each Source cell.
  • Executed on 2026-10-20: src/app.ts imported in-process with placeholder values for the four required variables, no env file and no preset, served on a random local port; the Repliers base URL pointed at a local server that never answers (REPLIERS_TIMEOUT=800), the Mapbox base URL and DB_PORT at closed ports. Results: GET /api/locations 500 with undefined - Repliers API error: undefined - /api/locations after the timeout; GET /api/autosuggest/address with a session 500 Internal Server Error with the TypeError in the debug fields (NODE_ENV=development); GET /api/vtour/some-slug 500 at once on ECONNREFUSED; a request without a session 400 from Joi.
  • Executed the same day: keyv with @keyv/redis as built by src/providers/keyv.otp.ts, against a closed port, without and with an error listener: get and set were pending after 8 s each and no exception reached the process.
  • Not established by this checkout: how long a Keyv call waits beyond 8 s, Redis or NATS behaviour after a connection that was working drops, the NATS server’s redelivery limits, FUB’s redelivery of a failed webhook, and Repliers’ own rate limiting.

Gotchas

  1. Mapbox and Google failures without a response lose the provider error. The TypeError from the .catch replaces it. Source: src/services/mapbox.ts, src/services/google.ts (request).
  2. The Repliers timeout does not cover the throttle queue. Source: src/services/repliers/base.ts (constructor and switchKey: the axios instance is wrapped by activeThrottler()), src/providers/throttler/ondelay.ts.
  3. A failed HTTP response does not mean nothing happened. Rows, published messages, Repliers clients and messages sent before the error stay. Source: src/services/boss/webhook.ts, src/services/agent.ts (syncBossPeople), src/services/auth.ts (side effects).

Verified against portal-backend 997ae3e, 2026-10-20.

Last updated on