Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jul 29, 2025

This PR fixes issue #6335 where users could access Test ErrorBoundary functionality in production builds, causing critical errors.

Problem

The exposeSourceMapsForDebugging function in sourceMapInitializer.ts was incorrectly exposing debugging functions like __testSourceMaps in production mode. This allowed users to trigger the Test ErrorBoundary functionality even after the UI button was removed, causing the error:

TypeError: Cannot read properties of undefined (reading 'nonExistentMethod')

Solution

  • Fixed the condition in exposeSourceMapsForDebugging to only expose debugging functions in development mode
  • Changed if (process.env.NODE_ENV !== "production") to if (process.env.NODE_ENV === "production") to return early in production
  • Added comprehensive tests to verify debugging functions are not exposed in production

Testing

  • Added new test file sourceMapInitializer.spec.ts with 4 test cases
  • Verified debugging functions are not exposed in production mode
  • Verified debugging functions are still available in development and test modes
  • All existing tests continue to pass

Impact

  • Prevents users from accessing Test ErrorBoundary functionality in production
  • Maintains debugging capabilities in development environment
  • No breaking changes to existing functionality

Fixes #6335


Important

Fix exposeSourceMapsForDebugging to prevent exposing debugging functions in production mode and add tests to verify behavior.

  • Behavior:
    • Fix exposeSourceMapsForDebugging in sourceMapInitializer.ts to prevent exposing debugging functions in production mode.
    • Change condition to if (process.env.NODE_ENV === "production") to return early in production.
  • Testing:
    • Add sourceMapInitializer.spec.ts with tests verifying debugging functions are not exposed in production.
    • Ensure functions are exposed in development and test modes.
    • Verify no errors when called multiple times in production.
  • Impact:
    • Prevents access to Test ErrorBoundary in production.
    • Maintains debugging in development.
    • No breaking changes.

This description was created by Ellipsis for 59aed9a. You can customize this summary. It will automatically update as commits are pushed.

- Fixed sourceMapInitializer.ts to only expose debugging functions in development mode
- Previously, __testSourceMaps function was exposed in production, allowing users to trigger errors
- Added comprehensive tests to verify debugging functions are not exposed in production
- Resolves issue where users could access Test ErrorBoundary functionality in production builds

Fixes #6335
@roomote roomote bot requested review from cte, jr and mrubens as code owners July 29, 2025 06:23
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jul 29, 2025
@roomote roomote bot mentioned this pull request Jul 29, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jul 29, 2025
@daniel-lxs
Copy link
Member

Closed by #6216

@daniel-lxs daniel-lxs closed this Jul 30, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 30, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Critical bug

4 participants