Skip to content

fix: defer cmd log to respect .quiet()/.verbose() overrides#1456

Closed
hobostay wants to merge 1 commit intogoogle:mainfrom
hobostay:fix/issue-931-quiet-verbose-cmd-log
Closed

fix: defer cmd log to respect .quiet()/.verbose() overrides#1456
hobostay wants to merge 1 commit intogoogle:mainfrom
hobostay:fix/issue-931-quiet-verbose-cmd-log

Conversation

@hobostay
Copy link
Copy Markdown

@hobostay hobostay commented Apr 19, 2026

Summary

Problem

Since PR #914 removed the setImmediate around run(), the start event fires synchronously during run(), which is called before chained methods like .quiet() or .verbose() can modify the snapshot. This means the cmd log entry always uses the original verbose/quiet state, ignoring per-call overrides.

Observed behavior:

  • .quiet() does not suppress the command line output
  • .verbose(false) does not suppress the command line output
  • .quiet(false) does not enable the command line output when $.quiet = true
  • .verbose(true) does not enable the command line output when $.verbose = false

Fix

Instead of reverting the setImmediate removal (which was needed for pipe splitting), this PR defers only the cmd log entry using queueMicrotask(). This is more targeted:

  • The process still starts synchronously (no change to spawn timing)
  • queueMicrotask runs after the current synchronous call stack completes but before any I/O, so chained methods have already executed
  • The timeout setup remains synchronous for correct timing

Test plan

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 19, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

When .quiet() or .verbose() is called on a ProcessPromise, the cmd log
was emitted before these overrides could take effect. This happened
because the start event fires synchronously during run(), which is
called before the chained methods execute.

Deferring the cmd log with queueMicrotask allows .quiet()/.verbose()
to modify the snapshot first, since microtasks run after the current
synchronous call stack completes.
@hobostay hobostay force-pushed the fix/issue-931-quiet-verbose-cmd-log branch from 70b487e to 216c4b7 Compare April 19, 2026 11:54
@antonmedv antonmedv closed this Apr 19, 2026
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.

Changed output behavior when using quiet and verbose in version 8.2.0

2 participants