Skip to content

Conversation

@peternhale
Copy link
Contributor

Summary

Fixes target-org resolution in the Apex debugger and resolves test failures related to unhandled promise rejections.

Changes

  • Extracted getTargetOrgConnection() method in apexDebug.ts and made it public for testability
  • Updated error handling in launchRequest to use early returns instead of throwing errors for expected conditions
  • Replaced sendEvent calls with errorToDebugConsole for pre-connection errors
  • Updated test stubs to properly mock ConfigAggregator.create() and Org.create() with valid target-org values
  • Exposed getTargetOrgConnection() in apexDebugForTest for testing
  • Removed unused OrgDisplay stub from tests

Testing

All 211 tests passing with no unhandled promise rejections.

@W-20111990@ #6558

chore: fix debugger tests

refactor: extract target-org resolution to method with error handling

- Extract target-org resolution logic into getTargetOrgConnection() method
- Method throws errors with appropriate messages for early exit
- Add try-catch around Org.create() to prevent unhandled exceptions
- Add test stubs for Org.create() to fix unhandled promise rejections
- Improve error handling consistency with early returns
@peternhale peternhale requested a review from a team as a code owner November 5, 2025 19:38
@peternhale peternhale requested review from RitamAgrawal and daphne-sfdc and removed request for RitamAgrawal November 5, 2025 19:38
Copy link
Contributor

@daphne-sfdc daphne-sfdc left a comment

Choose a reason for hiding this comment

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

Tested using the following steps: ✅

  1. Create a scratch org using the PBO org as the dev hub and set the "Debug Apex" permission according to these instructions: https://developer.salesforce.com/docs/platform/sfvscode-extensions/guide/interactive-debugger.html
  2. Set breakpoints in FileUtilities.cls of dreamhouse-lwc
  3. Add the "Launch Apex Debugger" launch configuration to launch.json
  4. Click the green play button to launch the Apex Interactive Debugger
  5. Open Developer Console in the scratch org
  6. Run FileUtilitiesTest.cls from Developer Console
  7. Make sure the breakpoints set in Step 2 are stopped

@peternhale peternhale merged commit 8f691d5 into develop Nov 7, 2025
146 of 147 checks passed
@peternhale peternhale deleted the phale/fix-apex-debugger branch November 7, 2025 12:52
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.

4 participants