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 / dependency | Catch / propagation | HTTP / task result | Completed side effects | Retry / fallback implemented | Source |
|---|---|---|---|---|---|
| Request validation (Joi) | Handler throws ApiError(error.message, 400) | 400, variant 1 | none; the service is not called | none | route files, src/validate/*.ts |
Authentication (koa-jwt, revocation lookup) | Strict: koa HttpError; passthrough: ApiError (verifying) | 401, variant 2 or 1 | none | none | src/providers/middleware/jwt/*.ts |
| Repliers, error response | RepliersBase.request rethrows ApiError("Repliers API error: <status>", <status>, <response body>) | the upstream status relayed, the upstream body in info, variant 1 | awaited writes earlier in the same request stay | none | src/services/repliers/base.ts (request) |
Repliers, no response (timeout REPLIERS_TIMEOUT, connection error) | same wrapper, with status undefined | 500, message undefined - Repliers API error: undefined - <path> (observed) | as above | none | src/services/repliers/base.ts (request) |
| Repliers throttle | p-throttle queues the call; nothing is rejected | none by itself; the wait adds to the response time | none | the queue is the only control; see Retry layers | src/providers/throttler/repliers.ts, repliersWarmup.ts |
| Mapbox or Google Maps, error response | ApiError("Mapbox API error") / ApiError("Google API error") with the provider status and body | provider status, variant 1 | none | none | src/services/mapbox.ts, src/services/google.ts (request) |
| Mapbox or Google Maps, no response | the .catch reads e.response.status with no response, which throws a TypeError | 500, variant 5: Internal Server Error, plus err, stack and file outside production (observed) | none | none | src/services/mapbox.ts, src/services/google.ts (request) |
Google Maps status other than OK / ZERO_RESULTS | a plain Error thrown from googleAddress | 500, variant 5 | none | ZERO_RESULTS gives [] | src/services/autosuggest.ts (googleAddress) |
| Autosuggest branches | Promise.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 error | the other branches’ upstream calls still complete | MLS-number branch: logged at debug level, yields null, the primary listings are returned alone | src/services/autosuggest.ts (search) |
| Mapbox address that the parser rejects | parseAddressSafe returns {} | 200; parts filled from the Mapbox context | none | parser fallback | src/services/autosuggest.ts (parseAddressSafe) |
| Google prediction that the parser rejects | per-prediction try | 200; that prediction is dropped | none | drop | src/services/autosuggest.ts (googleAddress) |
| Estimate enrichment (neighborhood, tax adjustment, average tax) | each step catches, logs at debug level and continues | 200 with the step’s value missing or unchanged (pipeline) | none | the unenriched value | src/services/estimate.ts (getAddressData, adjustPropertyTax, getAverageTax) |
| Follow Up Boss, from a request path | BossService.request rethrows ApiError("Boss API error", <FUB status>, <FUB body>) | FUB status, or 500 without a response, variant 1 | earlier awaited writes stay | BOSS_ENABLED=false: every call returns {} without a request | src/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 decided | the primary handler’s work | none; the event is lost | src/providers/middleware/eventsCollection.ts, src/services/eventsCollection/eventsCollection.ts |
| Event selector property lookup | getProperty catches | the event is still sent, with only mlsNumber and url for the property | none | reduced event | src/services/eventsCollection/selectors/baseEventCollectionSelector.ts (getProperty) |
| Registration event (signup, OAuth) | reportClientRegistration catches | none: sign-up continues | the Repliers client | none | src/services/auth.ts, src/services/oauth.ts (reportClientRegistration) |
| Agent send-estimate note | second handler written in the route, try / catch with console.error | none: the response was already decided | the estimate send of the primary handler | none | src/routes/agent.ts |
| Admin agent batch, one agent | per-item try / catch | 200; 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 missing | agents created before and after the failed one | none | src/services/admin.ts (createAgentsBatch, stringifyError) |
| PostgreSQL (unreachable, query error) | knex rejects with a driver error, not an ApiError | 500, variant 5; connection refused fails at once (observed) | every earlier statement: each repository call autocommits except the sync transaction (transaction boundaries) | none | src/repository/*.ts, src/app.ts |
| PostgreSQL pool exhausted | knex waits for a free connection | 500 after knex’s acquire timeout (library default 60 s; nothing in config.db sets it) | as above | none | src/config.ts (db.pool), knex 3.3.0 |
Redis-backed Keyv (REDIS_KEYV_ENABLE=true), Redis unreachable | the 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 exception | the request waits: every request with a token (the revocation lookup), every OTP request and every @cached read | none | no fallback to memory | src/providers/keyv.*.ts, src/lib/decorators/cached.ts, src/repository/blocklist.ts |
| In-memory Keyv (the default) | no dependency to fail | none | none | n/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 propagates | 500, variant 5 | none | none; 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, publish | awaited in order; any error propagates (handler steps) | FUB status or 500 to FUB | rows inserted and messages published before the error | none in the backend; FUB’s own redelivery is upstream behaviour, unverified | src/services/boss/webhook.ts (handlePeopleUpdated, handlePeopleCreated, handlePeopleDeleted) |
| Agent people sync: publish after commit | the publish loop runs after the commit; an error propagates | 500 | the sync and people_sync rows, and every message published before the error | none; nothing re-publishes a PENDING row | src/services/agent.ts (syncBossPeople), src/services/sync.ts (publishUpsert) |
NATS disabled (DummyNats) | publish resolves with nothing stored | 204 / { synced } as usual | job rows stay PENDING; no worker runs | n/a | src/lib/dummy.nats.ts |
| Worker job (Repliers, FUB, database) | caught in processUpsert / processPeopleUpsert / processPeopleDelete: status written, error rethrown; StreamWorker.process catches it | task status = the error text; message nak (outcomes) | Repliers client and FUB AVM-field writes made before the error | redelivery 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 JSON | message.json() throws in the handler, before any status write | nak; the row keeps its status | none | redelivery as above | src/streams/boss/people.ts, src/streams/worker.ts |
| Worker message on an unknown subject | no entry in eventMap | term | none | none | src/streams/worker.ts (process) |
| Startup (configuration, keys, port, NATS, webhook install) | not caught | the process exits (what stops a step) | for the webhook install: old webhooks deleted, some new ones created | worker NATS connect only, and it re-awaits one cached promise | src/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.
| Layer | Timeout | Throttle / queue | Retry | Source |
|---|---|---|---|---|
| Repliers HTTP | REPLIERS_TIMEOUT, default 30000 ms, per call (axios); it starts when the throttled call runs, so time in the queue is not counted | throttler: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 logged | none | src/services/repliers/base.ts (createAxios, activeThrottler), src/providers/throttler/*.ts |
| Mapbox | MAPBOX_TIMEOUT, default 30000 ms | none | none | src/services/mapbox.ts |
| Google Maps | GOOGLE_MAPS_TIMEOUT_MS, default 30000 ms | none | none | src/services/google.ts |
| Follow Up Boss | BOSS_TIMEOUT_MS, default 30000 ms | none | none | src/services/boss.ts |
| SMTP | none set (nodemailer defaults) | none | none | src/services/smtp.ts |
| PostgreSQL | none set: knex acquire timeout 60 s (library default), no statement timeout | pool min: 1, max: 5 per process | none | src/config.ts (db), src/providers/db.ts |
| Redis (Keyv) | none set | none | the Redis client reconnects with the backoff @keyv/redis installs (min(2^attempt × 100, 2000) ms plus jitter, no attempt limit); operations wait meanwhile | src/providers/keyv.*.ts, src/lib/decorators/cached.ts; @keyv/redis 5.1.6 |
| NATS connection | client library defaults (reconnect on, 10 attempts, 2 s apart) | none | worker 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/O | src/worker.ts, src/providers/nats.ts |
| NATS publish | JetStream API timeout, library default 5 s | each publish awaited before the next | none | src/services/boss/webhook.ts, src/services/sync.ts; @nats-io/jetstream 3.4.0 |
| Worker message | none; working() once at the start | one message at a time per process | nak with no delay, redelivered by the server; term for an unknown subject | src/streams/worker.ts |
| Worker consume loop | none | none | consume() called again at once after an iteration error | src/worker.ts |
| Inbound HTTP | none set in src/index.ts; Node’s defaults bound only the time to receive a request (requestTimeout 300 s, headersTimeout 60 s), not the handler | rate-limit /api/auth/* in front of the backend (limits) | none | src/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,stackandfileto the body whenNODE_ENVis notproduction(src/app.ts);NODE_ENVunset counts asproduction(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 theDummyNatsrow.REDIS_KEYV_ENABLEunset. 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.tsimported 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 andDB_PORTat closed ports. Results:GET /api/locations500 withundefined - Repliers API error: undefined - /api/locationsafter the timeout;GET /api/autosuggest/addresswith a session 500Internal Server Errorwith theTypeErrorin the debug fields (NODE_ENV=development);GET /api/vtour/some-slug500 at once onECONNREFUSED; a request without a session 400 from Joi. - Executed the same day:
keyvwith@keyv/redisas built bysrc/providers/keyv.otp.ts, against a closed port, without and with anerrorlistener:getandsetwere 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
- Mapbox and Google failures without a response lose the provider error. The
TypeErrorfrom the.catchreplaces it. Source:src/services/mapbox.ts,src/services/google.ts(request). - The Repliers timeout does not cover the throttle queue. Source:
src/services/repliers/base.ts(constructor andswitchKey: the axios instance is wrapped byactiveThrottler()),src/providers/throttler/ondelay.ts. - 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.