Skip to content

build: safeguard terminal styling in devkit admin script#32896

Merged
clydin merged 1 commit intoangular:mainfrom
clydin:build/fix-admin-log-error
Mar 30, 2026
Merged

build: safeguard terminal styling in devkit admin script#32896
clydin merged 1 commit intoangular:mainfrom
clydin:build/fix-admin-log-error

Conversation

@clydin
Copy link
Copy Markdown
Member

@clydin clydin commented Mar 30, 2026

Prior to this change, if an unhandled promise rejection or error occurred that lacked a stack property, the console.error wrapper in devkit-admin.mts would receive undefined. Attempting to pass undefined to Node's util.styleText caused an unexpected ERR_INVALID_ARG_TYPE crash instead of printing the original error.

This commit updates the console.warn and console.error overrides to ensure they only apply styleText to strings. It also updates the top-level try-catch block to fallback to the original error object if err.stack is undefined, preventing silent suppression.

Prior to this change, if an unhandled promise rejection or error occurred
that lacked a `stack` property, the `console.error` wrapper in
`devkit-admin.mts` would receive `undefined`. Attempting to pass
`undefined` to Node`s `util.styleText` caused an unexpected
`ERR_INVALID_ARG_TYPE` crash instead of printing the original error.

This commit updates the `console.warn` and `console.error` overrides
to ensure they only apply `styleText` to strings. It also updates the
top-level try-catch block to fallback to the original error object
if `err.stack` is undefined, preventing silent suppression.
@clydin clydin requested a review from alan-agius4 March 30, 2026 15:01
@clydin clydin added the target: patch This PR is targeted for the next patch release label Mar 30, 2026
@angular-robot angular-robot bot added the area: build & ci Related the build and CI infrastructure of the project label Mar 30, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates scripts/devkit-admin.mts to apply terminal styling to console.warn and console.error outputs and improves error logging by falling back to the error object if the stack trace is missing. The review feedback highlights a potential crash when using styleText in non-TTY environments and recommends verifying process.stdout.isTTY before applying styles.

@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Mar 30, 2026
@clydin clydin merged commit 54c96c8 into angular:main Mar 30, 2026
38 checks passed
@clydin
Copy link
Copy Markdown
Member Author

clydin commented Mar 30, 2026

This PR was merged into the repository. The changes were merged into the following branches:

@clydin clydin deleted the build/fix-admin-log-error branch March 30, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: build & ci Related the build and CI infrastructure of the project target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants