Skip to content

child_process: fix primordials usage in stderr truncation - #64804

Open
Rauneet-coder wants to merge 1 commit into
nodejs:mainfrom
Rauneet-coder:fix/child-process-stderr-primordials
Open

child_process: fix primordials usage in stderr truncation#64804
Rauneet-coder wants to merge 1 commit into
nodejs:mainfrom
Rauneet-coder:fix/child-process-stderr-primordials

Conversation

@Rauneet-coder

Copy link
Copy Markdown

Fixes #

Summary

Reuse the existing slice helper for stderr truncation in child_process.execFile().

The stdout truncation path already uses the local slice helper, while the stderr path calls chunk.slice() directly. This change makes both paths consistent by reusing the same helper without changing behavior.

Testing

  • Ran the relevant child_process tests.
  • Verified that stdout and stderr truncation behavior remains unchanged.

Proposed changelog entries

N/A

Proposed changelog category

/label skip-changelog

Proposed upgrade guidelines

N/A

In `execFile()`, the stderr `data` event handler was calling `chunk.slice(0, truncatedLen)` directly on the chunk object. This was inconsistent with stdout handling, which uses a safe local `slice` helper with `StringPrototypeSlice` for strings and a function wrapper for buffers.

This change updates the stderr handler to use the same `slice` helper, ensuring consistent primordials usage across both stdout and stderr stream truncation.

Signed-off-by: Rauneet Singh <[email protected]>
@nodejs-github-bot nodejs-github-bot added child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run. labels Jul 28, 2026
@avivkeller

Copy link
Copy Markdown
Member

How does this benefit node core?

@Rauneet-coder

Copy link
Copy Markdown
Author

The primary goal was to make the stderr truncation path consistent with the existing stdout implementation, which already uses the local slice helper. My intention was to reduce divergence between two equivalent code paths rather than introduce any behavioral change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants