Skip to content

fix(ext/node): add missing process.constrainedMemory() API#32209

Merged
bartlomieju merged 7 commits intodenoland:mainfrom
bartlomieju:fix/node-compat-process-tests2
Feb 18, 2026
Merged

fix(ext/node): add missing process.constrainedMemory() API#32209
bartlomieju merged 7 commits intodenoland:mainfrom
bartlomieju:fix/node-compat-process-tests2

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

@bartlomieju bartlomieju commented Feb 17, 2026

Summary

  • Extracts the cgroup v1/v2 parsing logic used by process.constrainedMemory() into a shared public cgroup module in ext/node/ops/process.rs
  • Reuses the shared parser from cli/lib/worker.rs (V8 heap limit configuration) instead of duplicating it
  • Moves the cgroup parsing unit tests to the new shared module
  • Enables parallel/test-process-constrained-memory.js test

🤖 Generated with Claude Code

bartlomieju and others added 6 commits February 16, 2026 19:58
Make process.config and its nested objects immutable via Object.freeze()
to match Node.js behavior. Enable test-process-config.js node compat test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…emory()

Add process.availableMemory() using Deno.systemMemoryInfo().available and
process.constrainedMemory() backed by a new op that reads cgroup memory
limits on Linux. Also freeze process.config for immutability. Enable
three node compat tests: test-process-config.js,
test-process-available-memory.js, test-process-constrained-memory.js.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix process event methods (on, off, emit, prependListener) to handle
Symbol event names by guarding `startsWith("SIG")` checks with a
`typeof event === "string"` check. Also fix process.emit to always
dispatch through EventEmitter rather than sending OS signals.
Enable test-process-emit.js and test-process-beforeexit-throw-exit.js
node compat tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract cgroup parsing logic used by `process.constrainedMemory()` into
a shared `cgroup` module in `ext/node/ops/process.rs`, and reuse it from
`cli/lib/worker.rs` instead of duplicating the parser.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bartlomieju bartlomieju changed the title refactor(ext/node): deduplicate cgroup memory limit parsing fix(ext/node): add missing process.constrainedMemory() API Feb 17, 2026
Replace disallowed `std::fs::read_to_string` calls in cgroup module
with `sys.fs_read_to_string` via the `ExtNodeSys` trait, matching
the pattern used elsewhere in the codebase.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@fraidev fraidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Also tested on docker with a log and I got the same result from node:

docker run --rm -m 256m -v $PWD:/app -w /app node node a.js
268435456
docker run --rm -m 256m -v $PWD:/app -w /app debian ./target/debug/deno a.js
268435456

@bartlomieju bartlomieju merged commit d590fb6 into denoland:main Feb 18, 2026
87 checks passed
@bartlomieju bartlomieju deleted the fix/node-compat-process-tests2 branch February 18, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants