[Repo Assist] fix: replace console.group/time with VS Code OutputChannel for debug logging#124
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…logging Fixes issue #14 ('TypeError: console.group is not a function'). Problems fixed: - console.group(), console.time(), console.timeEnd(), console.groupEnd() are not available in all VS Code extension host environments and throw TypeError when debug mode is enabled. - The phpcbfError stdout-capture pattern was completely broken: the flag was set inside an async callback but checked synchronously immediately after, so the stdout listener was never registered. - Exit code 3 left the Promise unresolved (hung), and referenced the removed phpcbfError variable which would throw in strict mode. Changes: - Add _debugLog() helper that writes to a VS Code OutputChannel (visible under View → Output → phpcbf) with a console.log fallback. - Replace console.group/time/timeEnd/groupEnd with _debugLog() calls. - Replace stderr console.log with _debugLog() so stderr is always captured in the Output panel (not just in debug mode). - Remove the dead phpcbfError pattern; stdout is now always streamed to _debugLog when debug is enabled. - Fix exit code 3: call reject() so the Promise settles and show an error notification. - Create OutputChannel in activate() and pass it to PHPCBF constructor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
66 tasks
github-actions bot
added a commit
that referenced
this pull request
Apr 2, 2026
Summarises all bug fixes that are ready to ship, drawn from the open Repo Assist PRs (primarily #106, #114, #117, #120, #124 and the earlier consolidated fixes). The version number in package.json is intentionally not changed here (that file requires maintainer action due to protected-file restrictions). This PR exists so the maintainer can review the intended release notes and bump the version when ready. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Apr 2, 2026
Open
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.
🤖 This is an automated pull request from Repo Assist.
Problem
Closes #14
When
"phpcbf.debug": trueis set, the extension crashes with:This occurs because VS Code's extension host does not expose
console.group(),console.time(),console.timeEnd(), orconsole.groupEnd()in some versions/environments.Additionally, the debug output was silently discarded:
phpcbfErrorwas set inside an asyncexitcallback but checked synchronously right after the Promise setup (alwaysfalse), so the stdout listener for error output was never registered — error output from phpcbf was completely swallowed.phpcbfError = truebut never calledresolve()/reject(), leaving the Promise permanently unresolved (hang), and in strict mode the undeclaredphpcbfErrorassignment would throw aReferenceError.Root cause
The extension used browser-style
console.group/console.timeAPIs that are not part of VS Code's extension host sandbox.Fix
_debugLog(message)helper on thePHPCBFclass that writes to a VS Code OutputChannel (View → Output → phpcbf), with aconsole.logfallback for testing outside VS Code.console.group,console.time,console.timeEnd,console.groupEndcalls with_debugLog().console.logwith_debugLog()so stderr is always visible in the Output panel (not just in debug mode).phpcbfErrorstdout-capture pattern; stdout is now streamed directly to_debugLogwhen debug is enabled.reject()so the Promise settles and show awindow.showErrorMessagenotification.OutputChannelinactivate()and push it tocontext.subscriptionsfor proper cleanup.Trade-offs
Debug output now appears in
View → Output → phpcbfinstead of the developer console. This is the VS Code-recommended approach and produces cleaner, always-accessible output for users.Test Status
✅ All 7 unit tests pass (
npm run test:unit).No new tests were added for this change — the debug path requires a live VS Code extension host and phpcbf binary. The fix eliminates the crash that was reported and removes dead code.