Repository navigation
Added
-
The pharn.dev link says how much traffic each commit served, so "no errors since the deploy" can
be told from "no requests since the deploy" (CORE-527). Each interval's request now carries an
optionaltrafficlist: per commit,requests(spans the collector received, one per incoming
HTTP request) anddropped(spans the agent dropped), withlowerBound: truewhendroppedis
above 0. Counts only: no path, method or status. A commit that served requests and raised no
error is still sent, once per interval, with an emptygroupslist; a process with no request
data (no HTTP, or none in the interval) sends notrafficentry rather than 0. Counted in
phargus servefrom the spans and drop counters the agent already writes: no new work in the
agent.docs/schema/production-errors.v1.jsonstays version 1:trafficis optional and
groupsmay now be empty. New typesPharnPayloadTrafficandPharnTrafficInput;
buildPharnPayloadtakes the counts as an optional third argument. -
A Next.js server error's frames can be mapped inside the function that threw (CORE-550). Next
writes a.mapnext to every server chunk, butoutput: 'standalone'and a Vercel function leave
them out;addNextServerSourceMapsToTraces(distDir), run fromnext.config's
compiler.runAfterProductionCompile, adds each traced chunk's map to Next's file traces and strips
itssourcesContent.mapErrorFramesInProcess(frames)then maps frames in the calling process
(no worker pool, nophargus serve) to the repository path and line, and leaves a frame it cannot
map at its built position withunmapped: true;reportNextErrornow maps its frames with it, so
an error sent from a function nameslib/thrower.tsand its line. Both are new exports of
@pharn-dev/phargus/analyzer, withDEFAULT_MAX_IN_PROCESS_MAP_BYTES(8 MiB). Checked on Next.js
16.4.6 underoutput: 'standalone'and on a Vercel preview deployment (docs/LIMITS.mdsection 8). -
A Next.js error on a serverless function reaches pharn.dev.
reportNextError(error, request, context)from@pharn-dev/phargus/pharn, called inonRequestErrorininstrumentation.ts,
builds the allow-listed payload for that one error and starts one request without making the
hook wait: the promise goes to the platform'swaitUntil(@vercel/request-context, no
dependency), else it runs on its own with a 5 s timeout, so a route handler's 500 is not delayed.
It readsPHARGUS_PHARN_KEY(no key: nothing sent, nofetch), takes the commit from
VERCEL_GIT_COMMIT_SHA(orPHARGUS_COMMIT), sends frames mapped in-process where the chunk's
map was shipped and otherwise at their built position flaggedunmapped, sends nothing from a
non-productionVERCEL_ENVunlessPHARGUS_PHARN_PREVIEW_KEYis set, keeps at most 10 requests in flight, and never throws. It does not need
@pharn-dev/phargus/agent, so no sampler or request tracing starts.examples/nextjs-app/serverless
is a real Next.js 16 app showing it, installed on its own. -
An optional link sends error groups to pharn.dev. It is off until a key is set:
phargus serve
readsPHARGUS_PHARN_KEY(andPHARGUS_PHARN_URLfor a test intake) from the environment, and
the agent ignores both. Every 10 seconds it sends one request with the errors seen since the last,
grouped by signature: per group the class, code, origin, frames (repository-relative path, line,
column, function, andunmapped; a frame that is not in-app is sent with its function name
only), commit, count, first and last seen, and once the Node.js version. Never the message, stack
text, request paths or absolute paths: the payload is built from an allow-list and matches
docs/schema/production-errors.v1.json, the schema pharn.dev validates. HTTPS only (http:to
loopback for tests), no redirects, the key only in anAuthorizationheader, a bounded queue with
retries and backoff, a 5-minute pause after a 401 or 403 (reported once), andpharn.droppedon
thecounts:line. New entry point@pharn-dev/phargus/pharn:createPharnExporter(the
collector listener),createPharnSenderandbuildPharnPayload(for an in-process reporter),
DEFAULT_PHARN_URL. A collector listener can now take anerrorcallback, called for every error
the collector keeps, not only the 10 a window lists. A test reads the built agent and fails if it
holds code that opens a connection. -
An error has a signature that survives a deploy. Every error a collector window lists carries
signature:v1:and the SHA-256 of its class and the repository path and function name of its
3 innermost in-app frames, with no line, column, message orcode, so an edit above a frame keeps
it and a renamed function gets a new one. Without in-app frames (a collector with no repository
root) it falls back to file basenames. A weak signature carriessignatureFlags(anonymous,
unmapped,no-in-app-frames); windows read back from disk get it recomputed. The algorithm is
specified indocs/API.mdso a receiver can recompute it, anddocs/LIMITS.mdsays when two
bugs merge and one splits. New collector exports:errorSignature,groupErrors(count, first
and last seen per signature) and typesErrorSignature,ErrorSignatureFlag,ErrorGroup,
SignableError. -
Error frames name the source file and line, not the built file. The collector maps each error's
frames through source maps, off its stream pipeline:createCollector({ symbolizeErrorFrames })
takes a function, andcreateErrorFrameSymbolizer({ repoRoot })from
@pharn-dev/phargus/analyzerbuilds one that runs on the symbolization worker, with its caps
(32 MiB per built file or map by default,DEFAULT_MAX_ERROR_MAP_BYTES) and reads confined to the
repository root.phargus serve --repo-root <dir>(orPHARGUS_REPO_ROOT) turns it on. Each
frame then carriesinApp, a repository-relativepath(in-app frames only: never a full path)
and, when it could not be mapped,unmapped: truewith its built position kept. A map whose
source lies outside the root is refused, a malformed map costs only its own file's frames, and a
dependency, a file outside the root or a Node internal frame isinApp: false. A symbolizer
failure keeps the error with the agent's frames and counts it (collector.symbolization,
collector.symbolizeFailedon thecounts:line). New exports:createErrorFrameSymbolizer,
DEFAULT_MAX_ERROR_MAP_BYTES,ErrorFrameSymbolizer,ErrorFrameSymbolizerOptions(analyzer),
and typesErrorFrame,SymbolizeErrorFrames,ErrorSymbolization(collector). -
captureError(error)(agent) reports an error your application handled: it writes the same
errorline as an uncaught exception, with originhandledand thetraceIdof the request in
progress, so a framework's 500 is tied to the error behind it. It accepts any value (a non-Error
is recorded by its type), never throws, does nothing while the agent is not running, and queues
the line in the agent's non-blocking output instead of writing it synchronously. At most 10
handled error lines are written per second; the rest are counted in the sample line's
dropped.errors(present once above 0), which collector windows keep and the dashboard shows.
The collector accepts originhandled.docs/API.mdand the README give recipes for an Express
error middleware, a FastifyonErrorhook and a Next.jsonRequestErrorininstrumentation.ts;
examples/express-appnow reports itsGET /errorthrough an Express-shaped error middleware,
and newexamples/fastify-appandexamples/nextjs-appcover the other two, without installing
any framework. -
Every window and span names the commit its process runs. The agent reads
PHARGUS_COMMITonce at
start, or else the first ofVERCEL_GIT_COMMIT_SHA,RENDER_GIT_COMMIT,
RAILWAY_GIT_COMMIT_SHA,HEROKU_BUILD_COMMITandHEROKU_SLUG_COMMITthat is set, and writes it
in one header line ({"type":"header","pid":…,"commit":"…"}) before any other line. A value that
is not 7 to 40 hexadecimal characters is ignored, counted (commitIgnored) and warned about on
stderr; the agent never runsgitor reads.git, and with no variable set no header line is
written. The collector attaches the commit to windows and spans (commit), the dashboard header
shows the short sha or "commit unknown", and OTLP resources carry it asvcs.ref.head.revision. -
The agent records uncaught exceptions and unhandled rejections. Each one becomes one NDJSON line
withtype: "error":class,code(only when it is letters, digits and_),origin
(uncaughtorrejection), up to 32frames(file,line,column,function) parsed from
the stack string, thetraceIdof the request in progress,pidandtimestamp. It is written
synchronously, so it reaches the output before the process exits. The agent listens on
uncaughtExceptionMonitoronly: whether the process dies, its exit code and its stderr do not
change. The message is left out unlessPHARGUS_ERROR_MESSAGES=1(config keyerrorMessages).
Collector windows carry anerrorsfield (countand the first 10 errors) when they received
any (each error with the run'scommit), persisted windows keep it, and the dashboard lists them. New types:ErrorRecord,
ErrorFrame,ErrorOrigin(agent),WindowError,WindowErrors(collector).
Fixed
- A process that was stopped and resumed (
SIGSTOP, a paused container, a suspended serverless
instance) no longer reports the stop as event-loop delay, and an event-loop alert no longer fires
on every resume. When the time since the agent's previous sample is longer than
max(5 × PHARGUS_INTERVAL_MS, 1 s), the event loop spent more than half of it idle and the
process used less CPU time than half of it, the sample carriessuspendedMs(the gap minus the
interval) and zeroeventLoopfigures. A busy loop, however long, stays event-loop delay: its
loop is not idle. The collector leaves such
samples out of a window's event-loop figures and counts them in the window's new optional
suspended: { count, totalMs }field, which persisted windows keep. Seedocs/LIMITS.md§9. - A stall that began right after a sampler tick, or was due with it, could vanish from every
sample: reading the event-loop histogram resets the timestamp its own timer measures from, so a
read that ran before that timer had recorded the stall dropped it. Above a 20 ms interval a tick
now reads its samplers only once the histogram's timer has recorded after it (or after a stall
that made the read late), checking every 20 ms for at most 200 ms. - On Windows with stdout a pipe, an uncaught exception that came while the agent's own stdout
writer had a sample line in flight lost itserrorline: the line was queued behind the sample
and the process exited first. Since the sampler change above, samples are written at the moment
an app's timer is likely to throw, so this happened often. The error line is now written at once
and lands whole before or after the line in flight; it is still queued behind a line only
part-written. Seedocs/LIMITS.md§1 and §3 for what remains (process.stdoutwith bytes queued by a
slow reader, and a Windows pipe whose reader has stopped).