Repository navigation
Conversation
|
Hi! I'm the It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! 😃 |
|
Dependency limit exceeded — report not shown. This pull request scan exceeded the 10,000-dependency limit applied to this scan, so the results are incomplete and may be inaccurate. To avoid reporting false positives, Socket has not posted a report. Upgrade your plan to raise the dependency limit and get complete reports, or view the partial scan in the dashboard. Socket is always free for open source. If this is a public open source project under an OSI-approved license, contact us to request a free Business plan upgrade. |
…rve:request:end While a channel has subscribers, Bun.serve publishes a request's start before it calls the fetch or route handler, with the channel's bound stores entered around that call, and its end once the response is sent or the client went away, with the status written and whether it was aborted. node:http keeps its own channels. Without subscribers nothing changes: one hook pointer is read per request. The N|Solid agent traces Bun.serve requests through these channels, the way it traces node:http through Node's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
…ics and handle counters The agent's Phase 3, with N|Solid's names, shapes and errors: - Traces. Spans for node:http (server and client), Bun.serve, fetch and node:dns, sampled at the root by traceSampleRate and carried between services in traceparent. A thread queues each span it ends; the agent exports them over OTLP TraceService every second, or at once past 1,000. The trace flags follow tracingEnabled and tracingModulesBlacklist (whose names are OR'd here; N|Solid adds them). - nsolid.otel: an application's @opentelemetry/api gets N|Solid's context manager and tracer provider while tracing is on, so its spans are custom spans in the same traces. - nsolid.logger: debug to fatal lines, with the active span, over OTLP LogsService. - HTTP and DNS metrics per thread: the five counters and the dns, httpClient and httpServer summaries (the median averages the two middle values, where N|Solid takes the lower one). - Handle counters per thread: activeHandles, activeRequests, and the created and destroyed counts of TCP and unix listeners and sockets (Bun.listen, node:net, Bun.serve, node:http), UDP sockets and node:fs file handles. - source_code: a script a thread loaded, by id and by path (a profile's file:// URL or a stack's path), read from disk when it is asked for, only while the Console has turned sourceCodeEnabled on. Off, it answers 500 "Source code reads disabled(1009)", a code N|Solid has yet to agree to. - Continuous CPU profiling: back-to-back windows of contCpuProfileInterval on every thread, each on its own ExportContinuousProfile stream; a manual profile answers 409 meanwhile. - The capabilities list the new command and settings. Span status is exported (errors, and fetch responses of 400 and up); N|Solid computes it but never sends it. Not done: http2 spans, ending spans still open at exit, and DNS spans for the lookups Bun's net and fetch make natively. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
… them, and format a test The enum of what the tracer records shadowed the global Record type; the channel subscribers take their messages as any, as the channel types give them; source_code reads the file synchronously, as N|Solid does on its agent thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
…N|Solid's does A lookup without `all` records the one address node:dns hands back (the resolver's list in the lookup's order, then the first), not the whole list; with `all`, every address with its family. On a host where localhost has both ::1 and 127.0.0.1, the span had the list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
…ad against the budget scripts/nsolid/stub-gateway.ts holds each agent's Command stream open, accepts every other call and counts the calls and bytes by method, so agents can run against it in measurements and test runs. scripts/nsolid/measure-overhead.ts measures one nsolid-bun binary with no agent, with the agent (metrics, event-loop and GC counters), and with tracing on at 100% and 10% sampling: startup, idle RSS and threads, idle CPU over 30 s, and the throughput, latency, peak RSS and trace exports of hello-world Bun.serve and node:http servers. It compares the deltas with the overhead budget (startup +2 ms, RSS +25 MB, idle CPU 0.5% of a core, Bun.serve throughput 3% lower at most). The server runs alone on one CPU, so the agent's work comes out of the core that serves requests; the load comes from two plain-socket clients on two other CPUs, so that they are not the bottleneck. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
…off and on, and report its overhead The nsolid-bun workflow ran only the N|Solid tests. Phase 3 changed node:http, node:dns, sockets, fs and Bun.serve, so eight jobs now run Bun's tests of those against the release build, with Bun's test runner (retries, test/expectations.txt, test/flaky-tests.txt): - node:http: test/js/node/http and Node's test-http-* tests; - node:net, dgram and dns: their test folders and Node's test-net-*, test-dgram-* and test-dns-* tests; - node:fs: test/js/node/fs and Node's test-fs-* tests; - Bun.serve and sockets: test/js/bun/http, net, udp and dns. Each runs with the agent off, as any process that does not ask for it, and with it on and tracing at 100%, every Bun process of the run reporting to a stub gateway. An overhead job runs scripts/nsolid/measure-overhead.ts on the build and puts the table in the run's summary, with the JSON as an artifact. Shared runners are noisy, so it reports and does not fail on the numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
… taking turns in a new order each round Against stock Bun, where the four setups are the same process, throughput moved 5% (Bun.serve) to 15% (node:http) between rounds on a shared host. The server's CPU time per request moves far less, since time the host gives to other machines is not counted in it, so the report gives it beside the throughput. Each round now starts with the next setup, and each figure is the median of 6 rounds of 8 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
…h the request channels' hook The server keeps such a handler wrapped with its context, and calls it through AsyncContextFrame::call. While bun:serve:request:start or :end had subscribers, the channels' hook called the wrapper itself, which is not callable: every request threw "handler.@call is not a function" and answered 500. That is every request of such a server while the N|Solid agent runs. jsFunctionCallInFrameOf (AsyncContextFrame.cpp) calls a function of the hook's with the wrapped handler, in the handler's context; the hook then enters the channel's stores over it and calls the handler. A handler sees its own store and the channel's, as one that is not wrapped does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
Bun's own node:http tests, run with the agent tracing, found the tracer in the program's view: - each server response had a 'finish' and a 'close' listener of the agent's, each client response an 'end' and a 'close' one, and each client request a symbol property; listener counts, emit()'s answer and the order of own keys changed; - req.headers was parsed before the program read it, and headersSent was read once more as a response ended. node:http now calls the agent from its own code: ServerResponse's emit for 'finish' and 'close', responseOnEnd and the client socket's close (in both texts of each module). The agent keeps its state in WeakMaps, reads the request's headers from the native handle's copy, and asks whether headers were sent only of a response it saw begin. The ahead-of-time text emits a response's events while the agent runs. Tests: an application's view of a node:dns lookup, and of node:http and Bun.serve exchanges, is the same with the agent tracing as without it. The Bun.serve trace test waits for its last request before its server goes away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
- fs.test.ts: the FileHandle test counts every fd of its process, and the agent's connection to the Console opens while it counts. It is skipped while NSOLID_GRPC is set. - node-http.test.ts: a test compares the heads of two requests, and with the agent tracing each carries a traceparent of its own. It compares them without that header. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
…om its exit Two node:http tests run Node.js and expect what Node 26 does; the jobs had GitHub's Node 24. They now set up the version pinned for Bun's CI machines. measure-overhead.ts timed `-e 0` from start to exit. With the agent the exit waits for the exit report to reach the Console, which Phase 0's build did not send, so the startup budget was read against both. It now gives the time to the script's first output and the time from there to exit apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
…ile the agent traces With tracing on, every request carries a traceparent: what N|Solid does too. test-http-max-headers-count, test-http-mutable-headers and the two test-http-proxy-request-* tests assert exactly which headers a request has, and fail on that header alone. They still run with the agent off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
d00268b to
de1c12f
Compare
de1c12f to
13754b7
Compare
Phase 3 of nsolid-bun, the fourth PR of the stack:
main)Phase 3 makes a Bun process traceable from the N|Solid Console: spans for its HTTP and DNS traffic in the same traces as the services around it,
nsolid.loggerlines and an application's own OpenTelemetry spans, the HTTP, DNS and handle metrics, source pulls and continuous CPU profiles. The Console-side Phase 3 work is in the Console repository, in a draft pull request of its own.Phase 3 items
TraceServiceexport, the trace flags fromtracingEnabledandtracingModulesBlacklisttraceparentpropagationdns,httpClientandhttpServersummariesactiveHandles,activeRequests, and the TCP, unix, UDP and fs created and destroyed countersnsolid.loggerover OTLPLogsServicensolid.otel.registerandregisterInstrumentations(the API bridge only, as decided)source_code, behind the Console'ssourceCodeEnabledcontCpuProfile,ExportContinuousProfile)Rebased on 2026-12-04 onto
mainat 6cab274, which brings in oven-sh/bun at 39b4945. The commit SHAs in this description are the rebased ones. What the rebase changed here: upstream's node:dns is a port of Node'slib/dns.js, so the DNS hooks moved intointernal/dns.ts(below); and sockets are counted from upstream's newSocketOwneropen and close events.What does this PR do?
Bun.serve's diagnostics channels (commit 6d6177b)
bun:serve:request:startorbun:serve:request:endhas subscribers, Bun.serve publishes each request's start before it calls thefetchor route handler, with the channel's bound stores entered around the call. It publishes the end once the response is sent or the client went away, with the status it wrote andaborted.The agent's Phase 3 (commit 834c805)
internal/nsolid/tracing.ts, on every thread the agent watches):HTTP GET,DNS lookup,http.urlabsolute with its query,http.status_code,dns.addressas JSON,thread.id,nsolid.span_type, and so on.traceSampleRate; children follow.traceparentis injected on node:http and fetch requests and read on node:http and Bun.serve requests.AsyncLocalStorageunder OpenTelemetry's context key, so a handler's fetch, DNS lookups and log lines belong to its request's span.TraceServiceevery second, or at once past 1,000 spans, with the metrics resource.'request'listeners in the request's span. node:dns (internal/dns.ts) calls the agent before its binding starts a query and before the query's callback runs, with the answer the application gets.httpServerCount,httpServerAbortCount,httpClientCount,httpClientAbortCountanddnsCount.httpServer,httpClientanddnssummaries give the median and 99th percentile of each metrics interval. Past 16,384 samples in one interval they come from a uniform random sample of them.Bun.listen, node:net, Bun.serve and node:http;open,close, FileHandle).activeRequestsis the work a thread sent off the thread that hasn't finished.activeHandlesis what holds its loop open, less those requests.nsolid.logger:debugthroughfatal, N|Solid's severities. Each line carries the span it was written in, and is stamped in nanoseconds when it is written. The lines go over OTLPLogsServicewith N|Solid's small resource.nsolid.otel:register(api)installs N|Solid's context manager and tracer provider as the API's globals while tracing is on, and takes them away when it turns off.startActiveSpanpasses the span to the callback and returns its result, as OpenTelemetry's API does; N|Solid's does neither.source_code:file://URL or a stack's plain path.sourceCodeEnabledon. Off, it answers 500Source code reads disabled(1009), a code to agree with the N|Solid team; N|Solid has no such setting yet.nsolid.start()cannot turn it on.contCpuProfileis on and assets are enabled, every thread is profiled in back-to-back windows ofcontCpuProfileInterval.ExportContinuousProfilestream, with the window's wall-clock start and end.source_codeis now a command.contCpuProfile,sourceCodeEnabled,traceSampleRate,tracingEnabledandtracingModulesBlacklistare now settings.Where this differs from N|Solid on purpose:
dns.addressis always a JSON string.Not done here:
http2.clienttracing channel to injecttraceparentfrom; they come after this PR.dnsCount.A fix for Phase 2's snapshot crash is in #4 (commit 17aa8ad), which this PR is rebased on: the snapshot builder now holds each edge's name from the collector's call, as JSC's own builder does. The crash only showed on CI's release build; the debug build never had it, so CI's run of #4 is what confirms the fix.
Added after review: Bun's own tests in CI, what they found, and what the agent costs
CI (
nsolid-bun.yml, commits 3ef1686 and later):test/expectations.txt,test/flaky-tests.txt):test/js/node/httpand Node'stest-http-*);test/js/bun/http,net,udp,dns).scripts/nsolid/stub-gateway.ts.traceparent, as with N|Solid.scripts/nsolid/measure-overhead.tsand writes its table to the run's summary. It reports and never fails on the numbers.What the agent-on runs found, and the fixes. With tracing on, the tracer changed what programs see:
AsyncLocalStoragecontext (commit 09a84c0). The server keeps such a handler wrapped with its context, and the request channels' hook called the wrapper itself, so every request answered 500.jsFunctionCallInFrameOf(AsyncContextFrame.cpp) lets the hook enter the handler's context, then the channel's stores, as the server would.'finish'and a'close'listener, client responses an'end'and a'close'one, and client requests a symbol property;req.headerswas parsed before the program read it, andheadersSentwas read one extra time.ServerResponse'semit,responseOnEndand the client socket's close, in both texts of each module.thengetter on an answer ran twice. That tracer wrapped the old node:dns; on the rebased stack node:dns is upstream's port of Node'slib/dns.js, and it calls the agent itself, as above.fs.test.ts's FileHandle test counts every fd of its process, so it is skipped whileNSOLID_GRPCis set;traceparent.Overhead, from the release build of 5f6744a on CI, before the rebase. The process runs on one CPU, so the agent's thread shares the core that serves requests: a one-core container.
Against the budget proposed in Phase 0:
The measurement method:
The follow-ups are in the tracker: count HTTP metrics natively, make spans that are not sampled carry only their context, hand spans over without JSON, and find the startup cost.
How did you verify your code works?
bun bd test test/js/bun/nsolid/nsolid-agent.test.ts: all 52 tests pass on the debug build. The 10 new ones cover:traceparent, and a log line in the handler carrying the handler's span;dnsCount;00, then sampled once a reconfigure sets the rate to 1;register;activeHandlesfalling after the closes;source_code: refused until the Console turns it on, then answered by path and byfile://URL, with 1007 and 1002 errors;bun bd test test/js/bun/http/serve.test.ts -t diagnostics_channel: the 2 new tests pass, and fail on stock Bun.tcp-server.test.ts, node:dgram and the DNS resolver tests pass with this build.bun bd lintpasses.http_server_count,http_client_countanddns_count, and anhttp_serverp99;nsolid.loggerline through the logs search, with its request's trace;file://URL, then refused again;als.run(), with a store bound tobun:serve:request:start, answers 200 and sees both stores.Not run locally: clippy and mordant (CI runs them), and a release build (it did not fit this machine's time and memory; CI builds one).
After the rebase: every check passes at 13754b7, the eight Bun test jobs with the agent off and on included. The overhead job there measured the same costs within about 3 points: Bun.serve CPU per request +9.1% with the agent, +260% tracing at 100%, +92% at 10%. Locally, on the debug build, the 52 agent tests pass, and node:http, node:fs, perf_hooks and node:dns fail the same tests with the agent on as with it off; the exceptions are 9 node:dns tests, which time out at 5 s or run out of file descriptors only on the debug build, and pass in CI's release build.
https://claude.ai/code/session_013nEe5T77UhAYmQxqQRbPpR
Generated by Claude Code