Skip to content

🐛 URGENT: Fix production crash from bare console.* stripping#4248

Merged
clubanderson merged 1 commit intomainfrom
fix/production-crash
Apr 2, 2026
Merged

🐛 URGENT: Fix production crash from bare console.* stripping#4248
clubanderson merged 1 commit intomainfrom
fix/production-crash

Conversation

@clubanderson
Copy link
Copy Markdown
Collaborator

PRODUCTION IS DOWN

PR #4239 added bare console.log/console.debug to Vite's define config. Vite's define does literal text replacement — it replaced console.log(...) with undefined(...) inside vendor dependencies (Tailwind Merge, etc.), causing:

TypeError: (void 0) is not a function
  at bA (vendor-Dj3uwf9i.js:4724:194)

This crashes the entire app on console.kubestellar.io — blank page, React never mounts.

Fix

Remove bare console.* forms from Vite define. Only use globalThis.console.* which is specific enough to target our code without hitting vendor code.

Verified

  • grep -c "void 0(" dist/assets/vendor-*.js returns 0 after fix (was crashing before)
  • Build passes

PR #4239 added bare `console.log`/`console.debug` to Vite's define config
to strip debug calls. But Vite's define does LITERAL text replacement —
it replaced `console.log(...)` with `undefined(...)` in vendor/dependency
code (Tailwind Merge, etc.), causing `TypeError: (void 0) is not a function`
and crashing the entire app on console.kubestellar.io.

Fix: Only use `globalThis.console.*` form which is specific enough to
match our code but not vendor dependencies.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Copilot AI review requested due to automatic review settings April 2, 2026 14:48
@kubestellar-prow kubestellar-prow bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Apr 2, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 2, 2026

Deploy Preview for kubestellarconsole ready!

Name Link
🔨 Latest commit 832e2ee
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/69ce81c4b1ca9d00088e071d
😎 Deploy Preview https://deploy-preview-4248.console-deploy-preview.kubestellar.io
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@clubanderson
Copy link
Copy Markdown
Collaborator Author

/lgtm
/approve

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@kubestellar-prow kubestellar-prow bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 2, 2026
@kubestellar-prow
Copy link
Copy Markdown
Contributor

@clubanderson: you cannot LGTM your own PR.

Details

In response to this:

/lgtm
/approve

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@clubanderson clubanderson merged commit d1181e1 into main Apr 2, 2026
13 of 16 checks passed
@kubestellar-prow
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: clubanderson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow bot deleted the fix/production-crash branch April 2, 2026 14:48
@kubestellar-prow kubestellar-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a production outage caused by Vite define doing literal replacements of bare console.*, which impacted vendor bundles and produced runtime TypeError crashes.

Changes:

  • Removes bare console.log/info/debug/trace replacements from vite.config.ts to avoid altering vendor/dependency code.
  • Updates the inline documentation to warn against using bare console.* with define because of unintended vendor replacements.

Comment on lines 55 to 58
'globalThis.console.log': 'undefined',
'globalThis.console.info': 'undefined',
'globalThis.console.debug': 'undefined',
'globalThis.console.trace': 'undefined',
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

Defining globalThis.console.* to undefined will turn any matching call site into undefined(...), which throws a TypeError at runtime (the same failure mode described in the PR). Use a callable no-op (or another strategy that removes calls without leaving an uncallable identifier) so any surviving globalThis.console.*(...) becomes a safe no-op instead of a crash.

Suggested change
'globalThis.console.log': 'undefined',
'globalThis.console.info': 'undefined',
'globalThis.console.debug': 'undefined',
'globalThis.console.trace': 'undefined',
'globalThis.console.log': '((..._args) => {})',
'globalThis.console.info': '((..._args) => {})',
'globalThis.console.debug': '((..._args) => {})',
'globalThis.console.trace': '((..._args) => {})',

Copilot uses AI. Check for mistakes.
Comment on lines +50 to 59
// Strip console calls in production (replaces terser drop_console).
// IMPORTANT: Only use globalThis.console.* — bare "console.log" does
// literal text replacement that hits vendor/dependency code too,
// turning their console.log(...) into undefined(...) which crashes.
...(mode === 'production' ? {
'globalThis.console.log': 'undefined',
'globalThis.console.info': 'undefined',
'globalThis.console.debug': 'undefined',
'globalThis.console.trace': 'undefined',
'console.log': 'undefined',
'console.info': 'undefined',
'console.debug': 'undefined',
'console.trace': 'undefined',
} : {}),
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

With the bare console.* defines removed, this config no longer strips typical console.log/info/debug/trace usage in the app (only the rare globalThis.console.* form, which appears unused). Either adjust the comment/intent to reflect that console calls are no longer stripped, or update the stripping approach so it actually targets the app code without touching vendor dependencies.

Copilot uses AI. Check for mistakes.
@clubanderson
Copy link
Copy Markdown
Collaborator Author

🔄 Auto-Applying Copilot Code Review

Copilot code review found 1 code suggestion(s) and 1 general comment(s).

@copilot Please apply all of the following code review suggestions:

  • web/vite.config.ts (line 58): 'globalThis.console.log': '((..._args) => {})', 'globalThis.console.info':...

Also address these general comments:

  • web/vite.config.ts (line 59): With the bare console.* defines removed, this config no longer strips typical console.log/info/debug/trace usage in

Push all fixes in a single commit. Run cd web && npm run build && npm run lint before committing.


Auto-generated by copilot-review-apply workflow.

clubanderson added a commit that referenced this pull request Apr 2, 2026
Adds a postbuild script that scans vendor bundles for `void 0(` — the
minified form of `undefined()` — which indicates Vite's define config
replaced `console.*` calls in dependency code. This would have caught
the production crash from PR #4239 / #4248 before deployment.

Also removes unused DEV_BAR_HEIGHT_PX import blocking tsc.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
clubanderson added a commit that referenced this pull request Apr 2, 2026
tsc fails on this unused import, preventing Netlify from deploying the
production crash fix (#4248). This import was removed in #4244 but
re-introduced by #4245.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
clubanderson added a commit that referenced this pull request Apr 2, 2026
…ld (#4253)

tsc fails on this unused import, preventing Netlify from deploying the
production crash fix (#4248). This import was removed in #4244 but
re-introduced by #4245.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
clubanderson added a commit that referenced this pull request Apr 2, 2026
Adds a postbuild script that scans vendor bundles for `void 0(` — the
minified form of `undefined()` — which indicates Vite's define config
replaced `console.*` calls in dependency code. This would have caught
the production crash from PR #4239 / #4248 before deployment.

Also removes unused DEV_BAR_HEIGHT_PX import blocking tsc.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
clubanderson added a commit that referenced this pull request Apr 2, 2026
#4252)

Adds a postbuild script that scans vendor bundles for `void 0(` — the
minified form of `undefined()` — which indicates Vite's define config
replaced `console.*` calls in dependency code. This would have caught
the production crash from PR #4239 / #4248 before deployment.

Also removes unused DEV_BAR_HEIGHT_PX import blocking tsc.

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has signed the DCO. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants