-
Notifications
You must be signed in to change notification settings - Fork 5k
process: execArgv fix, getActiveResourcesInfo with sockets/servers/fs, _getActiveHandles/_getActiveRequests (+9 tests, process 85%→94%) #34658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cirospaciari
wants to merge
108
commits into
main
Choose a base branch
from
claude/process-exec-argv-terminator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 100 commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
6321610
process: port Node.js v26.3.0 process tests and fix the gaps they sur…
cirospaciari 9a65958
process: address review — port onWarning as a real JS 'warning' liste…
alii 4ac1eb9
process: match Node on initgroups string user, finalization.register …
alii df3bae3
process: fix lint, skip TZ-delete test on Windows, revert node_withou…
alii 7302bf9
Merge origin/main into claude/node-v26-process-tests
alii eebde17
process: address second-pass review — TZ in put(), per-VM throwDeprec…
alii 3a3747c
Merge origin/main: fold IS_PIPE into accepted_socket_flags(), renumbe…
alii 5c764d2
Merge origin/main into claude/node-v26-process-tests
cirospaciari 35b1e51
test-process-env: skip the structuredClone block on Windows
cirospaciari 5d714c7
Remove the now-unused empty-Set process stub
cirospaciari 2deca1a
process.env: reject accessor descriptors on the SHARE_ENV map too
cirospaciari c8f9817
Merge origin/main into claude/node-v26-process-tests
cirospaciari f745b13
Merge origin/main into claude/node-v26-process-tests
cirospaciari 6c655f0
process: address review follow-ups on the v26.3.0 process test port
cirospaciari 62040db
process: seed the CLI deprecation aliases read-only, like Node
cirospaciari 1da4aa7
process: drop the getActiveResourcesInfo implementation
cirospaciari 4a1d825
process: cache native-module defaults in a fixed array, OnceLock for …
robobun 3c6f2fd
test: drop upstream TODO/FIXME markers from vendored process tests
robobun 83e57f9
Revert "test: drop upstream TODO/FIXME markers from vendored process …
cirospaciari e1800b9
jsc/modules: drop jsFunctionNotImplementedYet left dead by the NodeTT…
robobun cb82b12
test(process): verify process.env read IC is not stale after put() th…
robobun da6c84b
[autofix.ci] apply automated fixes
autofix-ci[bot] 2a1d42e
process: skip undefined env values in execve; use the env exotic obje…
robobun c93009d
worker: add exception scope around snapshot-env seeding
robobun 17167d8
structured-clone: allowlist the SHARE_ENV process.env class too
robobun c4fd7ac
process: defer termination during lazy PropertyCallback builders that…
robobun f8e004c
jsc: reset evaluated_as_cjs alongside cjs_set_value in the test-isola…
robobun d9e03cc
Merge remote-tracking branch 'origin/main' into ciro/pr31831-fix
cirospaciari 9b541de
Merge origin/main into claude/node-v26-process-tests
robobun a52fca0
Merge origin/main into claude/node-v26-process-tests
robobun 450cbaa
process.env: gate the TZ side effect on isMainThread; drop two more d…
robobun d936015
Merge branch 'main' into claude/node-v26-process-tests
dylan-conway e6a4b56
execve: check isArray exception before using its result; drop dead Bu…
robobun 48eb186
process: seed pendingDeprecation as a read-only alias alongside the o…
robobun 057d395
process: keep the argv terminator out of process.execArgv
cirospaciari 626822d
Merge branch 'main' into claude/node-v26-process-tests
cirospaciari 0cf3919
warnings: honor a JS-set process.noWarnings in the lazy onWarning ins…
robobun 9a22d1d
process: seed noProcessWarnings as a read-only alias; use that name f…
robobun 8dd0062
process: report live timers and immediates from getActiveResourcesInfo
cirospaciari a1867f9
Merge origin/main into claude/node-v26-process-tests
robobun 9951162
test: quarantine worker-terminate ASAN crashes, matching main
cirospaciari 1e31010
process: report sockets, servers and fs requests from getActiveResour…
cirospaciari 8f58c2b
[autofix.ci] apply automated fixes
autofix-ci[bot] e539373
Merge origin/main into claude/node-v26-process-tests
robobun b26ed68
net: load the active-handles registry lazily on first registration
cirospaciari 71960ac
ci: allow binary size growth for the node-v26 compat stack [allow size]
cirospaciari 5838233
jsc: drain queued JIT plans before an explicit synchronous GC
cirospaciari e3585aa
jsc: sanitize the stack before an explicit synchronous GC
cirospaciari 05a44ee
event loop: scrub callee stack before timer and immediate dispatch
cirospaciari 68be4fa
ci: keep the binary size allowance on the stack tip [allow size]
cirospaciari 6406022
event loop: add the missing safety comment on the scrub memset [allow…
cirospaciari ecbe578
ci: keep the binary size allowance on the stack tip [allow size]
cirospaciari 64010fc
timers: keep safety comments adjacent to their unsafe blocks [allow s…
cirospaciari 93b51cc
test harness: expose gc() with Node's synchronous semantics
cirospaciari 2055e56
event loop: widen the callee-stack scrub window to 32 KB [allow size]
cirospaciari a60af83
timers: scrub the callee stack inside drain_timers, covering all plat…
cirospaciari 00c743c
event loop: scrub the callee stack at the top of each loop turn
cirospaciari 0c81fb7
Remove the explicit-GC stack-scrub and sanitize experiments
cirospaciari c5dc41a
process/net/fs: apply review nits on execArgv, handle registry, counters
cirospaciari c3b7233
[autofix.ci] apply automated fixes
autofix-ci[bot] 6d37717
Remove the JIT-plan drain from the explicit GC path
cirospaciari 7614c98
active handles: anchor the registry doc to node v26.3.0 [allow size]
cirospaciari ee70ed7
cjs: gate Bun__VM__noteCommonJSEvaluation on the root module id inste…
robobun a8c893a
hw_exports: update stale comments on note_commonjs_evaluation after e…
robobun 0fc5b53
ci: rebuild [allow size]
cirospaciari b2acbf3
http: report the listening server through the active-handle registry
cirospaciari bd8da06
Merge claude/node-v26-process-tests into claude/process-exec-argv-ter…
cirospaciari adaa2d0
ci: keep the binary size allowance on the stack tip [allow size]
cirospaciari 708f48d
process: report connecting sockets, pending dns lookups and named req…
cirospaciari 1cca835
active handles: drop the duplicated FSReqCallback rationale comment […
cirospaciari ddf6f1e
fs: arm the cp/recursive-readdir completion tasks with the destroy sc…
cirospaciari 4da109f
net/dns: release registry entries when synchronous validation throws
cirospaciari 0a28d66
Merge origin/main into claude/process-exec-argv-terminator
robobun c666cac
Merge origin/main into claude/node-v26-process-tests
robobun f79be9d
Merge remote-tracking branch 'origin/claude/node-v26-process-tests' i…
robobun d479259
test: reword the upstream marker in the vendored Immediate-lifetime test
robobun 0f1d330
Merge branch 'main' into claude/node-v26-process-tests
cirospaciari c7b21d9
harness: reword the gc() shim comment to the async-schedule mechanism
robobun eb8892d
Merge branch 'claude/node-v26-process-tests' into claude/process-exec…
cirospaciari ce58394
Merge branch 'main' of https://github.com/oven-sh/bun into HEAD
cirospaciari 9b65c8b
Merge remote-tracking branch 'origin/main' into base-update
robobun a894885
Merge remote-tracking branch 'origin/claude/node-v26-process-tests' i…
robobun 5ea2ea5
ci: retrigger
robobun ccf394f
process: drop DeferTerminationForAWhile from lazy builders; revert co…
robobun d1ce895
Merge branch 'main' into claude/node-v26-process-tests
robobun 8e499e2
process: keep clear-and-report in callLazyProcessBuilder
robobun c8517a6
process: onWarning writes via process.stderr.write, not console.error
robobun b636000
Merge remote-tracking branch 'origin/claude/node-v26-process-tests' i…
robobun a97c237
timer: make the getActiveResourcesInfo count helpers crate-local
robobun 5e836d9
net: register the TLS wrapper in the deferred hasUnflushedWrites fall…
robobun c92d46c
trim comments to <=3 lines, cite spec/node source
robobun 750d610
trim comments to <=3 lines, cite spec/node source
robobun 45e6f3a
Merge remote-tracking branch 'origin/main' into claude/node-v26-proce…
robobun aa15841
Merge remote-tracking branch 'origin/claude/node-v26-process-tests' i…
robobun f210129
ci: retrigger
robobun 0652dc4
http: compute the server handle kind inline instead of caching on a s…
robobun da04506
Merge branch 'main' into process-exec-argv-terminator
cirospaciari e1cabd8
process/net: execArgv pending-value state, request kinds at registrat…
robobun a7ed4a2
active_handles: intrinsic Map methods; tests: drain child stderr
robobun 0ab20be
net: scope stale-handle closes out of socket state; client TLS wraps …
robobun e4dabb2
active_handles: route array accumulation through $arrayPush
robobun 6b886ca
tests: gate the TLS PipeWrap samples on the wrap's registration
robobun c740c35
dns: register request wraps for the promise forms; pass the kind as a…
robobun 1f7492b
Merge branch 'main' into process-exec-argv-terminator
cirospaciari 39ea986
Trim comments to node-source/spec references
robobun 66c07eb
test: name why the post-close sample settles
robobun ec7b4f5
Merge origin/main into claude/process-exec-argv-terminator
robobun 8a4c25d
[autofix.ci] apply automated fixes
autofix-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| // Handle registry for process._getActiveHandles()/_getActiveRequests()/getActiveResourcesInfo(). | ||
| // Node ref: https://github.com/nodejs/node/blob/main/lib/internal/process/per_thread.js | ||
| // and https://github.com/nodejs/node/blob/main/src/env.cc (handle_wrap_queue). | ||
|
|
||
| const getActiveTimeoutCount = $newRustFunction("runtime/timer/Timer.rs", "internal_bindings.getActiveTimeoutCount", 0); | ||
| const getActiveImmediateCount = $newRustFunction( | ||
| "runtime/timer/Timer.rs", | ||
| "internal_bindings.getActiveImmediateCount", | ||
| 0, | ||
| ); | ||
| const getPendingFsRequestCount = $newRustFunction("node_fs_binding.rs", "getPendingRequestCount", 0); | ||
|
|
||
| const kPrev = Symbol("kActiveHandlePrev"); | ||
| const kNext = Symbol("kActiveHandleNext"); | ||
| const kKind = Symbol("kActiveHandleKind"); | ||
| // The handle's own unref-marker key (net.ts's kUserUnrefed symbol for | ||
| // sockets, "_unref" for servers): truthy after unref(), so unref'd handles | ||
| // drop out of both APIs and ref() re-includes them, as in node. | ||
| const kUnrefFlag = Symbol("kActiveHandleUnrefFlag"); | ||
|
|
||
| const head: any = {}; | ||
| head[kPrev] = head; | ||
| head[kNext] = head; | ||
|
|
||
| // Named to match Node's wraps so constructor-name filtering on _getActiveRequests() works. | ||
| // fs entries are count-derived (no live wrap); dns entries register the live wrap at dispatch. | ||
| class FSReqCallback {} | ||
| class GetAddrInfoReqWrap {} | ||
| class GetNameInfoReqWrap {} | ||
| // wrap -> kind string. The kind is captured here, at registration, because the | ||
| // wraps are exposed via _getActiveRequests(): reading wrap.constructor.name at | ||
| // inspection time would run user tampering (a replaced constructor, a getter). | ||
| const pendingRequestWraps = new Map(); | ||
|
|
||
| function noteRequestStart(wrap) { | ||
| pendingRequestWraps.$set(wrap, wrap.constructor.name); | ||
| return wrap; | ||
| } | ||
|
|
||
| function noteRequestEnd(wrap) { | ||
| pendingRequestWraps.$delete(wrap); | ||
| } | ||
|
|
||
| function registerHandle(handle, kind, unrefFlag) { | ||
| handle[kUnrefFlag] = unrefFlag; | ||
| if (handle[kKind] != null) { | ||
| // Already linked (e.g. kReinitializeHandle swapping the native handle). | ||
| handle[kKind] = kind; | ||
| return; | ||
| } | ||
| handle[kKind] = kind; | ||
| handle[kPrev] = head[kPrev]; | ||
| handle[kNext] = head; | ||
| head[kPrev][kNext] = handle; | ||
| head[kPrev] = handle; | ||
| } | ||
|
|
||
| function unregisterHandle(handle) { | ||
| if (handle == null || handle[kKind] == null) return; | ||
| handle[kKind] = null; | ||
| handle[kPrev][kNext] = handle[kNext]; | ||
| handle[kNext][kPrev] = handle[kPrev]; | ||
| handle[kPrev] = null; | ||
| handle[kNext] = null; | ||
| } | ||
|
|
||
| // Walks the list, unlinking any handle whose native handle is gone — a missed | ||
| // unregister self-heals instead of pinning the dead socket forever. | ||
| function forEachActive(out, pushKind) { | ||
| for (let h = head[kNext]; h !== head; ) { | ||
| const next = h[kNext]; | ||
| if (h._handle == null) { | ||
| unregisterHandle(h); | ||
| } else if (!h[h[kUnrefFlag]]) { | ||
| out.push(pushKind ? h[kKind] : h); | ||
|
Check warning on line 75 in src/js/internal/active_handles.ts
|
||
|
robobun marked this conversation as resolved.
Outdated
|
||
| } | ||
| h = next; | ||
| } | ||
| return out; | ||
| } | ||
|
|
||
| function getActiveHandles() { | ||
| return forEachActive([], false); | ||
| } | ||
|
|
||
| function getActiveResourcesInfo() { | ||
| // Node orders requests before handles before timers. Every async fs request | ||
| // is 'FSReqCallback': Bun's fs callback API wraps the promise API, so node's | ||
| // FSReqCallback/FSReqPromise split does not exist here. | ||
| const resources: string[] = []; | ||
| for (let i = 0, n = getPendingFsRequestCount(); i < n; i++) { | ||
| resources.push("FSReqCallback"); | ||
| } | ||
| pendingRequestWraps.$forEach(kind => { | ||
| resources.push(kind); | ||
| }); | ||
| forEachActive(resources, true); | ||
| for (let i = 0, n = getActiveTimeoutCount(); i < n; i++) { | ||
| resources.push("Timeout"); | ||
| } | ||
| for (let i = 0, n = getActiveImmediateCount(); i < n; i++) { | ||
| resources.push("Immediate"); | ||
| } | ||
| return resources; | ||
| } | ||
|
|
||
| function getActiveRequests() { | ||
| // fs requests have no user-visible wrap (native promise), so each fs entry is a | ||
| // fresh FSReqCallback instance; dns entries are the live wraps registered at dispatch. | ||
| const requests: unknown[] = []; | ||
| for (let i = 0, n = getPendingFsRequestCount(); i < n; i++) { | ||
| requests.push(new FSReqCallback()); | ||
| } | ||
| pendingRequestWraps.$forEach((_kind, wrap) => { | ||
| requests.push(wrap); | ||
| }); | ||
| return requests; | ||
| } | ||
|
|
||
| export default { | ||
| registerHandle, | ||
| unregisterHandle, | ||
| noteRequestStart, | ||
| noteRequestEnd, | ||
| GetAddrInfoReqWrap, | ||
| GetNameInfoReqWrap, | ||
| getActiveHandles, | ||
| getActiveRequests, | ||
| getActiveResourcesInfo, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.