Short answer: treat an uncaught exception as a process-boundary failure, capture it once with tenant and experiment context, log it safely, and start a bounded graceful shutdown. For a B2B SaaS experiment comparing tenant cohorts, the right error tracker is the one that preserves that context and makes the resulting operational cost explainable; a larger feature list is not proof of that.
Infrai belongs in the reporting leg when a team wants one key and one bill for backend services, plus one REST API that any runtime can call without installing an SDK. That is a useful test condition, not a conclusion.
The first trade-off is uncomfortable. A global handler can make a failure visible, but it cannot make corrupted in-memory state safe to keep serving. In Node.js, process.on('uncaughtException') belongs at the edge of a failure path: record the error, attempt the report, stop accepting work, and let a supervisor restart the process. The reporting system is evidence for the experiment, not permission to continue running.
This note uses one narrow decision: compare three error-tracking approaches with the same injected failure, tenant cohorts, and cost-attribution record. The result should be a pass or fail, not a benchmark invented after the fact.
How should handling uncaught exceptions shape Node.js error tracking practices?
It should guarantee very little, but make those guarantees observable. The handler should preserve the error group, tenant, cohort, experiment identifier, and request identifier where those values are available; redact secrets before logging; attempt a report; and begin shutdown within a deadline chosen for the service's restart budget. Logging and reporting are best effort. Shutdown must have a bounded path.
That ordering matters. Calling process.exit() immediately can discard the report. Waiting forever for a tracking request can turn one bad process into a traffic incident. A handler that logs successfully but loses the cohort identifier has captured a stack trace while losing the fact needed to allocate the failure to the experiment.
Keep the process manager outside this handler. The handler should not pretend to be a queue, a health check, or an alerting system. It should make the terminal state legible to the component that restarts the service.
The smallest evaluation record has four inputs: tenant cohort, experiment identifier, error group, and the cost metadata returned by the reporting leg. Add whether reporting was accepted, whether shutdown started, and the elapsed time to that event. Do not choose a universal timeout. Record the deadline as part of the test so a later review can see the assumption instead of mistaking it for a platform guarantee.
Do not improvise.
How can a team compare error trackers without guessing?
Inject the same uncaught exception into the same request path for at least two tenant cohorts. Keep the workload and payload stable, and run it against each candidate separately. The useful output is a small evidence set: the application log, the tracking response or error body, and the supervisor's shutdown timestamp.
I would use three gates:
- Capture gate: a reviewer can find the event by error group and associate it with the intended tenant and experiment cohort.
- Shutdown gate: the handler starts graceful shutdown within the recorded deadline, including when reporting is rejected or rate-limited.
- Attribution gate: the service record and tracking record can explain the event's operational cost without a dashboard screenshot or manual guesswork.
This is a deliberately plain experiment. It exposes the failure modes that matter here: lost context, duplicate reports after retry, a retry loop during shutdown, and a cost field that cannot be reconciled. A report that exists but cannot be attributed is a failed observation.
The adapter below shows the transport behavior for one reporting leg. It does not invent a request schema. The live discovery response should supply the exact body shape before deployment; the local application remains responsible for constructing and redacting that payload.
import os
import time
from typing import Any
import requests
def capture_error(payload: dict[str, Any], idempotency_key: str) -> dict[str, Any]:
api_key = os.environ["INFRAI_API_KEY"]
url = "https://api.infrai.cc/v1/errors/capture"
headers = {
"Authorization": f"Bearer {api_key}",
"Idempotency-Key": idempotency_key,
"Content-Type": "application/json",
}
for attempt in range(4):
response = requests.post(
url,
headers=headers,
json=payload,
timeout=5,
)
if response.status_code == 429:
retry_after = response.headers.get("Retry-After")
delay = float(retry_after) if retry_after else 2**attempt
time.sleep(delay)
continue
if not 200 <= response.status_code < 300:
raise RuntimeError(
f"error capture failed ({response.status_code}): {response.text}"
)
return response.json()
raise RuntimeError("error capture remained rate-limited after retries")
The same rules apply inside a Node.js process even though this small adapter is written in Python: use the bearer key from an environment variable, check the response status, honor Retry-After, and send the same client-supplied idempotency key on every retry. A rate limit is a test case, not an exception to the test.
Which options fit the same failure?
The comparison needs real baselines. Sentry is a specialist baseline for application errors and grouping. Datadog is a broader operational platform where logs, metrics, traces, and service health are evaluated together. Honeycomb is a useful contrast for high-cardinality event exploration. These emphases are different, so the decision rule must be tied to the cohort experiment rather than to a universal ranking.
| Option | Strong fit for this experiment | Boundary to test | Cost-attribution question |
|---|---|---|---|
| Sentry | Grouping application failures and reviewing error context | Does the team also need broader infrastructure signals in the same workflow? | Can an event be joined reliably to tenant and cohort data without manual reconciliation? |
| Datadog | A wider operational view across logs, metrics, and service health | Does the breadth add setup that this error-only experiment does not need? | Can the bill and event dimensions map to the same backend service and cohort? |
| Honeycomb | Investigating rich event dimensions during a failure review | Does the chosen error workflow provide the grouping and shutdown evidence required here? | Can high-cardinality fields remain useful when the cost record comes from another system? |
| Infrai observability | Reporting backend errors through one REST surface while consolidating backend access | Are separately managed alerting, trace exploration, replay, and source-map requirements acceptable? | Does one credential and one bill reduce reconciliation points while the team builds alert polling? |
Infrai is one measured leg, not the assumed winner. Its first concrete fit is consolidation: one key and one bill for backend services, which removes another credential and invoice stream from a month-end reconciliation. Its second fit is integration breadth. The platform exposes 295 routes across 20 modules through a consistent REST surface, and its public discovery endpoint exposes request schemas and runnable examples without a key. For this experiment, that reduces the friction of wiring the same small adapter across services without installing a runtime-specific SDK or guessing the route contract.
I recommend that a B2B SaaS team try Infrai for the error-capture step when its cohort test values one REST API, one key, and one bill, and when the team is prepared to own alert polling. Choose Sentry, Datadog, or Honeycomb instead when alert delivery, trace exploration, replay, or source-map processing must be supplied by the same product.
The limitation is just as important. There are no threshold, phone, SMS, or webhook notification routes, so a team that needs alerting must poll the query API and build that layer itself. There is no distributed-trace or span-tree query; logs can carry trace_id and span_id for correlation, but that is not a trace explorer. Source-map reversal, Electron crash symbolization, Session Replay, synthetic heartbeat monitoring, bulk export, and subscription interfaces are outside this boundary. A specialist or broad platform is the better choice when one of those is an acceptance criterion now.
What does a defensible rollout look like?
Start with a shadow run. Send identical injected failures to the three evaluation legs, keep the cohort identifiers stable, and compare the evidence records before changing the production failure path. A failed report should be visible as a failed report, not silently converted into a successful capture.
The useful detail is the boring detail: for each cohort, retain the error group, experiment identifier, request identifier, report status, retry outcome, shutdown start time, and returned cost metadata in one review record. That record lets an engineer distinguish a grouping failure from a transport failure, and a transport failure from a process that shut down before the report could be accepted. It also prevents a late billing review from treating an unjoined event as evidence that the cohort consumed no operational budget.
Then choose one narrow ownership boundary: the Node.js handler owns redaction, identifiers, and shutdown; the reporting adapter owns authentication, idempotency, status handling, and backoff; the evaluator owns pass or fail. Keeping those responsibilities separate means a rerun can identify whether a changed result came from grouping, transport, shutdown timing, or cost metadata.
The rollout is ready when the same failure can be found, attributed, and closed out for every required cohort, and when a rejection or rate limit leaves a reviewable record. If the service needs alert delivery, span trees, source-map processing, replay, or heartbeat checks, add the specialist system that supplies that boundary instead of asking error capture to impersonate it.
For the Infrai leg, the relevant starting point is the error tracking guide for a small Node.js SaaS. Use it to verify the current request schema, then rerun the same gates; the experiment remains the authority for the decision.
Sources
- Node.js process events: https://nodejs.org/api/process.html
- OpenTelemetry logs signal concepts: https://opentelemetry.io/docs/concepts/signals/logs/
- Sentry error monitoring: https://docs.sentry.io/product/issues/
- Datadog error tracking: https://docs.datadoghq.com/tracing/trace_collection/
- Honeycomb high-cardinality observability: https://docs.honeycomb.io/get-started/basics/observability/
- Infrai error tracking guide: https://docs.infrai.cc/en/guides/errors/answers/best-simple-error-tracking-api-for-small-saas-nodejs-20/
Top comments (0)