Skip to content

fix(core): remove debug code that runs in production builds#10834

Open
yogeshwaran-c wants to merge 1 commit intoswagger-api:masterfrom
yogeshwaran-c:fix/remove-debug-code-production
Open

fix(core): remove debug code that runs in production builds#10834
yogeshwaran-c wants to merge 1 commit intoswagger-api:masterfrom
yogeshwaran-c:fix/remove-debug-code-production

Conversation

@yogeshwaran-c
Copy link
Copy Markdown

Description

Removes development-only debug code that was executing in production builds:

  1. debug.jsx: window.props = this.props was exposing internal component props globally in all environments. Now wrapped in process.env.NODE_ENV === "development" check, which Webpack's DefinePlugin will dead-code eliminate in production builds.

  2. examples-select.jsx: Default onSelect prop contained a console.log call with a FIXME comment ("remove before merging to master"). Replaced with a no-op function.

  3. examples-select-value-retainer.jsx: Default onSelect and updateValue props contained console.log calls. Replaced with no-op functions.

Motivation and Context

Fixes #10521

  • Security: window.props exposed internal application state to the browser console in production
  • Console pollution: Debug log messages appeared in production builds
  • Code quality: The FIXME comment in examples-select.jsx explicitly asked for the debug code to be removed

How Has This Been Tested?

  • Verified the changes compile correctly
  • The window.props assignment is now gated behind a development environment check
  • The no-op functions maintain the same interface as before without side effects
  • All existing tests should continue to pass since the debug code was not tested

Screenshots (if appropriate):

N/A

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

- Wrap window.props assignment in debug.jsx with NODE_ENV check
  so it only executes in development builds
- Remove debug console.log from ExamplesSelect default onSelect prop
  (marked with FIXME: remove before merging to master)
- Remove debug console.log from ExamplesSelectValueRetainer default
  onSelect and updateValue props
- Replace debug callbacks with no-op functions

Fixes swagger-api#10521
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.

Remove Development Debug Code from Production Builds

1 participant