Repository navigation
v0.2.0
Security
- Behavior change:
symbolizeStackFramesnow confines reads to the working directory whenroots
is left out. Frames whose built file or source map lies outside the working directory are no
longer read; they come back unchanged unless you passrootsnaming the directories to read
from, orroots: nullfor the old unconfined behavior. - Dashboard login no longer puts the token in a request line. Open
/login#token=<token>: the
token is in the URL fragment, which the browser never sends; the public login page removes it
from the address bar and history, then posts it as JSON to the newPOST /session(4096-byte
cap, JSON only, constant-time compare), which answers204with the sameHttpOnly,
SameSite=Strictsession cookie, or401with none.phargus serveand the dashboard script
now point at this link./?token=<token>still works but is deprecated and will be removed in a
later release; the first use emits aPHARGUS_DEP_TOKEN_QUERYdeprecation warning.
Added
-
PHARGUS_CONFIGpins the agent's config file. When set, the agent loads exactly that.json
or.jsfile (a relative path resolves against the working directory) and does not look for
phargus.config.jsonorphargus.config.jsthere. An empty value, a missing or unreadable
file, something that is not a regular file, or any other extension rejects with a
PhargusConfigErrornamingPHARGUS_CONFIG, and never falls back to the working-directory
lookup.docs/THREAT-MODEL.mdgains row I1 for the config file as code-execution surface. -
phargus serve, a command-line way to get the dashboard without writing a collector. The
package now has abin, sonode --import @pharn-dev/phargus/agent app.mjs | npx phargus serve
reads the agent's NDJSON from stdin (or-), replays a capture file given as an argument,
aggregates it into windows and serves the dashboard. Flags:--port(default 7070),--host
(default127.0.0.1),--token,--window-ms(default 1000) and--max-line-bytes, plus
--helpand--version.PHARGUS_TOKENsupplies the token, and a non-loopback--host
without one is refused with exit code 2 before anything binds. Diagnostics go to stderr only:
the dashboard URL, an input-ended line and acounts:line (decoder.invalid,
decoder.oversized,collector.ignored,dashboard.droppedEvents). The server keeps running
after the input ends. SIGINT and SIGTERM close the server and the collector and exit 0; a stuck
shutdown is forced out with exit code 1 after 5 seconds. Exit codes: 0 success, 1 runtime error
(unreadable file, port in use), 2 usage error. Errors print without a stack unless
PHARGUS_DEBUGis set. The CLI is ESM-only and is not anexportssubpath.
@pharn-dev/phargus/dashboardnow also exportsisLoopbackHost.npm run check:exports,
check:packageandcheck:installverify thebin. -
phargus serve --allowed-host <host>, repeatable, passed to the dashboard'sallowedHosts.
It lets a browser reach a server bound with--host 0.0.0.0(for example in a container) by
IP or hostname instead of getting421. A bare name matches on any port;host:portmatches
exactly. An empty value, or one with whitespace or/, is a usage error (exit code 2). It does
not lift the token requirement for a non-loopback--host. -
Webhook alert sinks take an optional
headersoption, for example
{ authorization: 'Bearer …' }, sent with every request (review finding F23). It works on
createWebhookSinkand on a{ type: 'webhook' }sink config. Headers are copied and checked
when the sink is created: a name must be an HTTP token, a value must be a string with no control
characters (tab aside) and nothing above U+00FF, and the same name twice in different case is
rejected.content-typeis reserved for the sink's ownapplication/json, so supplying it is a
TypeErrorrather than a silent override.__proto__is rejected too, because Node'sfetch
drops it. Errors name the header, never its value. -
OTLP metrics export (
@pharn-dev/phargus/otel) now carries every window field (review finding
F22). New gaugesphargus.gc.pause.maxandphargus.backpressure.stall.max(ns); new delta
monotonic sumsphargus.gc.pause.totalandphargus.backpressure.stall.total(ns),
phargus.backpressure.events({event}),phargus.window.samplesand
phargus.window.late_samples({sample}, from the window'scountandlate). The metrics
resource now carriesservice.instance.id,host.nameandprocess.pidbeside
service.name, so several instances no longer merge into one series.service.instance.id
defaults to a random UUID generated once per process; the newserviceInstanceIdoption on
createOtlpMetricsExporterandtoOtlpMetricsoverrides it, and an empty or non-string value
throws aTypeError. The trace exporter is unchanged. -
docs/API.md, a reference of every supported export per subpath.npm run check:exportsnow
also compares each subpath's runtime export names with an exact expected list, throughimport
andrequire, and fails on a name added or missing.
Fixed
- Lower memory cost of HTTP tracing under load. The tracer's span buffer kept each of its 1024
most recent spans as an object plus four strings, and under load each lived long enough to be
promoted by V8 and die in the old generation (about 3× the agent-off promotion rate on a
promise-heavy server, and about 25 MiB more RSS after a minute). Spans are now stored as bytes
in preallocated slots, which take about 280 KiB for the default 1024 spans. Promotion and
steady-state RSS now match the agent-off run. What is buffered, dropped and exported is
unchanged. - Lower per-request CPU cost of HTTP tracing. Trace and span ids are now cut from a 4 KiB buffer
of CSPRNG bytes refilled as it runs out, instead of onerandomBytes()call (and Buffer) per
id; a CPU profile of the overhead benchmark put those calls at about 16% of the busy time of a
traced server. Ids keep their format (lowercase hex, never all zeros) and no byte is used twice. - The dashboard no longer reports a normal SSE client disconnect as a server error. A write to a
connection the client had already closed (EPIPE) is now treated likeECONNRESET: the client
is cleaned up andonError(or the process warning) is not called. Other errors on an SSE
response or socket are still reported, and cleanup stays idempotent. summarizeHeapSnapshotanddiffHeapSnapshots(@pharn-dev/phargus/analyzer) no longer time
out on large snapshots within a raisedmaxSnapshotBytes(review finding F27). The task timeout
is nowmax(30 s, size / 20 MB/s), summed over both files for a diff, computed by the new
heapSnapshotTimeoutMs(bytes)export. It applies when notimeoutMsis passed and the pool is
the one the call makes or one fromcreateHeapSnapshotPool()withouttaskTimeoutMs. An
explicittimeoutMsalways wins, and a pool made withtaskTimeoutMs,createWorkerPoolor
anything else keeps its own timeout. At the default 256 MiB cap the timeout stays 30 s.- Collector persistence no longer backpressures
consume()(review finding F25). A slow disk used
to hold every window up behind the append, all the way back to the source. Windows now go
through a bounded queue and are appended one at a time, in emission order, off the pipeline.
persist.maxQueueSizesets how many wait (default 1024); it must be a positive safe integer,
orcreateCollectorthrows aRangeError. When the queue is full the oldest window is dropped.
collector.persistence.droppedcounts those drops andcollector.persistence.failedcounts
windows whose append failed (both integers). A failed append still rejectsconsume()with the
append error, now without waiting for the source to end.close()and the end ofconsume()
wait for the queue to drain, with no time limit, so a disk that never completes an append
stallsclose().close()stops accepting windows before it drains, so aconsume()still
running cannot hold it open; a window that arrives after it is counted infailed. - OTLP exporters (
@pharn-dev/phargus/otel) no longer lose spans and windows under load (review
finding F2). They used to send one request per exported span or window, with one request in
flight, and silently dropped the newest batch once 64 were queued. They now batch: pending
items go out in one request whenmaxBatchSize(default 512) items are pending or after
flushIntervalMs(default 1000 ms), one request at a time. At mostmaxQueueSize(default 2048) items are held; when full, the OLDEST pending items are dropped, counted and reported
throughonErroras aggregated "dropped" reports. New countersdroppedItems,exportedItems
andfailedItemssit besidedroppedBatchesandfailedBatches. The flush timer is
unref()ed and armed only while items are pending. A record that cannot be encoded fails only
itself. Behaviour change: one export call is no longer one request, and the first send waits up
toflushIntervalMsunless a full batch is pending; callclose()orflush()before exit.
queueCapacityis deprecated: still accepted and validated, but it no longer bounds anything
(the queue holds items, not batches); usemaxQueueSize. - Dashboard: a client that connects to
/eventsnow receives the collector's whole history
(every buffered alert, window and span) instead of losing part of it to the live-event drop
queue; with full buffers it previously got no alerts and a truncated window history. The replay
is written in one call outside that queue, alerts first, then windows, then spans.
maxBufferedEventsanddroppedEventsnow cover live events only. - Dashboard: a request whose
Hostis not allowed still gets421, but now with a short
text/plainbody naming theallowedHostsoption andphargus serve --allowed-host(review
finding F24). It used to be bodyless, so behind a proxy or a container port map the browser
showed a blank page. The rejectedHostis not echoed back. - The collector no longer dies on non-agent stdout lines.
collector.consume()now accepts any
parsed records: foreign records (not agent data) and malformed ones (agent-shaped but unusable)
are skipped and counted incollector.ignored, with an optionalonIgnoredhook, instead of
rejectingconsume(). Malformed agent records are skipped rather than thrown. The new
createNdjsonDecoderexport turns the byte stream into objects with bounded line memory and
counts non-object (invalid) and over-long (oversized) lines. - Event loop figures no longer include the 10 ms timer interval (review finding F16). The
sampler's histogram records the whole interval on every tick, so an idle process reported a min
of about 10 ms and a p50 of about 11 ms, the dashboard showed that as lag, and any alert
threshold below about 12 ms always fired.createEventLoopSamplernow passes an explicit
resolutiontomonitorEventLoopDelayand subtracts it from min, max, mean, p50 and p99,
clamped at 0 in integer nanoseconds, so the values are delay beyond the timer interval and an
idle loop reads close to 0. It takes an optional{ resolution }(whole milliseconds, default
10; anything else throws aRangeError), and the agent exports theEventLoopSamplerOptions
type. Behaviour change: every event loop value, and every window and OTLP metric built from it,
is about 10 ms lower. The bundledphargus/event-loop-lagrule (100 ms default) and the
example app's 50 ms alert are unchanged; a threshold you set close to 10 ms now fires only on
real delay.
Changed
- The agent no longer warns about
PHARGUS_TOKENandPHARGUS_DEBUG. They belong to
phargus serve, and the agent now ignores them silently, so a shell or container that runs
both sides of the pipe can set them once. Other unknownPHARGUS_*variables still warn. - Releases now publish on merge: a PR that bumps the version (with its lockfile and a
## [X.Y.Z]section here) is the release. Every push tomainruns the jobs gate, build,
publish and release, which release only whenpackage.json's version has no tag yet; the GitHub
Release notes are that version's section of this file.NPM_PUBLISH_ENABLEDstill has to be
truefor the publish and release jobs to run. Checks for the release notes, the version files
and the workflow run undernpm test. - CI: the non-required
node-latestworkflow now also runsPlatform smokejobs on
windows-latestandmacos-latest(review finding F21). On the.nvmrcNode floor they run
npm ci, build,check:exportsandnpm test, so platform-specific code paths (plugin child
script paths, the symbolizer worker, process groups) get some CI coverage. The required checks
still run on Linux only..gitattributesnow checks text files out with LF on every platform.
On Windows, the tests for signal-driven graceful shutdown, a non-writable heap snapshot
directory, the packed bin's execute bit and the release-workflow check are skipped;
docs/LIMITS.mdrecords these limits. The idle event loop tests now bound p50 by the sampler's
resolution instead of 5 ms, because Windows timers leave an idle loop at about 5 ms.
Removed
- The public entry points of
@pharn-dev/phargus/agent,/collector,/dashboardand
/plugin-runnerno longer export internals and scaffold placeholders (review findings F18,
F19). This is breaking for 0.x consumers that imported them. What is left is the list in
docs/API.md. Removed:agent:encodeNdjsonLine,createSpanExport,SpanExport,enable,disable,
drainSpans,DEFAULT_SPAN_BUFFER_SIZE,HttpTracingOptions,SpanDrain,toSpanRecord,
isSpanRecord,PhargusAgentPlaceholdercollector:createWindowAggregator,WindowAggregatorOptions,createSpanRouter,
parseWindowLine,serializeWindow,CollectorPlaceholderdashboard:DashboardPlaceholderplugin-runner:PluginRunnerPlaceholder