Skip to content

fix(frontend): prevent crash on ? keypress with vanilla Kafka#2274

Open
weeco wants to merge 1 commit intomasterfrom
fix/2262-question-mark-crash-vanilla-kafka
Open

fix(frontend): prevent crash on ? keypress with vanilla Kafka#2274
weeco wants to merge 1 commit intomasterfrom
fix/2262-question-mark-crash-vanilla-kafka

Conversation

@weeco
Copy link
Contributor

@weeco weeco commented Mar 9, 2026

Summary

Fixes #2262 — pressing ? crashes the console with React error #301 (too many re-renders) when connected to vanilla Kafka without Redpanda Admin API.

Three interacting bugs caused the crash:

  • setup({}) called on every rendermemoizeOne uses reference equality, but {} creates a new object each time, so memoization never worked. Every App re-render re-created gRPC clients and fired API calls.
  • Missing .catch() on listEnterpriseFeatures — on vanilla Kafka this returns 501. The unhandled rejection cascaded into MobX observable mutations during render, pushing React past its re-render limit.
  • useKey('?') triggered unnecessary re-renders — the hook maintains internal pressed state even though the callback is a no-op in production, so every ? keypress forced an App re-render.

Changes

  • app.tsx: Move setup() into a useEffect with empty deps and use a stable argument reference
  • backend-api.ts: Add .catch() handler to listEnterpriseFeatures call
  • use-developer-view.ts: Split into dev/prod implementations — production reads localStorage directly without useKey, avoiding wasted re-renders

Test plan

  • bun run type:check passes
  • bun run lint passes (no new warnings)
  • bun run test passes (478/478 tests, 1 pre-existing skip)
  • Manual: connect console to vanilla Kafka, press ?, verify no crash
  • Manual: connect console to Redpanda, press ? in dev mode, verify developer view toggle still works

Three interacting bugs caused React error #301 (too many re-renders)
when pressing `?` on a console instance connected to vanilla Kafka:

- setup({}) was called on every render with a new object, defeating
  memoizeOne's reference equality check
- listEnterpriseFeatures lacked a .catch() handler, causing unhandled
  rejections (501) on vanilla Kafka that cascaded into re-render loops
- useKey('?') maintained unnecessary pressed state triggering App
  re-renders even though the callback is a no-op in production
@weeco weeco requested a review from jvorcak March 9, 2026 16:06
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.

Pressing ? crashes the console when using vanilla Kafka without Redpanda

2 participants