fix(@angular/cli): restore console methods after logger completes#32828
Merged
clydin merged 1 commit intoangular:mainfrom Mar 25, 2026
Merged
fix(@angular/cli): restore console methods after logger completes#32828clydin merged 1 commit intoangular:mainfrom
clydin merged 1 commit intoangular:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the restoration of original console methods (log, info, warn, error) in the finally block to ensure consistent output from late consumers. The review suggests an improvement to make this restoration more robust and explicit by storing all original console methods in a single object to avoid assumptions and potential issues with chained assignments during restoration.
Member
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
console.log()when called afterfinallywill be dropped. This could become an issue if code prints late likeeslintwhich usesprocess.on("exit")to print timing information. This code will run after the logger has completed and will be dropped.This means that
TIMING=all ng lintdoes not work, eventhougheslintis seeing the var and collecting the data, but fails to print becauseconsole.log()is dead.What is the new behavior?
Once the logger is completed, we reinsert
console.log,console.info,console.warnandconsole.errorso that any console logs that happens to trigger as the process is exiting, will still be printed to stdout.Maybe there's a way to keep the logger living for longer, but since it's doing asyncronous things, I don't think we can clean it up in
process.on('exit')or similiar? This fix at least prints to stdout as a best effort.Does this PR introduce a breaking change?
Other information
Ran into this issue by trying to print the timing information when using
ng lint(angular-eslint), and realised that they werent doing anything weird, the console log was running, it was just disapparing. After some more tracking I realised that angular-cli was the one hijacking console.log(), so hoping to clean out this little tripwire.