Skip to content

fix(i18n): reset embedded start guard and align menu error handling#41491

Open
rusackas wants to merge 4 commits into
masterfrom
fix/followup-40729-follow-up-from-40729-fix-i18n-defer-plug
Open

fix(i18n): reset embedded start guard and align menu error handling#41491
rusackas wants to merge 4 commits into
masterfrom
fix/followup-40729-follow-up-from-40729-fix-i18n-defer-plug

Conversation

@rusackas

Copy link
Copy Markdown
Member

Follow-up to #40729.

That PR deferred plugin init and menu render until the language pack is ready, but left two rough edges in the error handling that this tightens up.

SUMMARY

  • embedded/index.tsx: start() chains off the pluginsReady promise, but that chain had no rejection handler. If setupPlugins() or setupCodeOverrides() throws, pluginsReady rejects, the chain rejects unhandled, and the started guard stays true forever, so a retry just returns early and the embedded dashboard is stuck in a failed state. This adds a rejection handler to the pluginsReady.then(...) in start() that logs the error and resets started = false so a rehandshake can retry, mirroring the existing guest-token failure path.
  • menu.tsx: replaces the empty .catch(() => {}) with the same try/finally + logging.error pattern already used in views/index.tsx, so the menu still always renders (import/render in finally) but unexpected failures get logged instead of swallowed.

No behavior change on the happy path; this only hardens the failure paths.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A (error-path hardening, no visual change).

TESTING INSTRUCTIONS

  1. Embedded: force a throw inside setupPlugins()/setupCodeOverrides() and confirm the error is logged and started resets so a retry can proceed, rather than the dashboard hanging.
  2. Menu: force initPreamble() to reject and confirm the menu still renders (in English) and any unexpected render error is logged.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

@dosubot dosubot Bot added change:frontend Requires changing the frontend embedded i18n Namespace | Anything related to localization labels Jun 27, 2026
@bito-code-review

bito-code-review Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #582f3e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 1e74f1b..1e74f1b
    • superset-frontend/src/embedded/index.tsx
    • superset-frontend/src/views/menu.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot removed i18n Namespace | Anything related to localization embedded labels Jun 27, 2026
Comment thread superset-frontend/src/embedded/index.tsx
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. The current implementation of start() in superset-frontend/src/embedded/index.tsx relies on a module-level pluginsReady promise that, once rejected, remains in a permanently rejected state. Subsequent calls to start() will immediately trigger the rejection handler, preventing any recovery or retry of the plugin initialization.

To resolve this, you should refactor pluginsReady to be a function that returns a new promise, or re-initialize the promise upon failure. Here is a concise fix for superset-frontend/src/embedded/index.tsx:

// Replace the module-level pluginsReady promise with a factory function
const getPluginsReady = () =>
  initPreamble().then(async () => {
    await Promise.all([import("src/setup/setupPlugins"), import("src/setup/setupCodeOverrides")]);
    setupPlugins();
    setupCodeOverrides({ embedded: true });
  });

// Then update start() to call getPluginsReady()
function start() {
  // ...
  return getPluginsReady().then(
    () => { /* ... success path ... */ },
    err => { /* ... failure path ... */ }
  );
}

I have checked the PR comments and there are no other comments to address. Would you like me to implement this fix for you?

superset-frontend/src/embedded/index.tsx

const getPluginsReady = () =>
  initPreamble().then(async () => {
    await Promise.all([import("src/setup/setupPlugins"), import("src/setup/setupCodeOverrides")]);
    setupPlugins();
    setupCodeOverrides({ embedded: true });
  });

function start() {
  // ...
  return getPluginsReady().then(
    () => { /* ... success path ... */ },
    err => { /* ... failure path ... */ }
  );
}

@codecov

codecov Bot commented Jun 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.85714% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.72%. Comparing base (7cdfe3f) to head (2be68a4).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
superset-frontend/src/embedded/index.tsx 80.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41491      +/-   ##
==========================================
+ Coverage   64.70%   64.72%   +0.01%     
==========================================
  Files        2686     2686              
  Lines      148625   148637      +12     
  Branches    34298    34298              
==========================================
+ Hits        96164    96198      +34     
+ Misses      50696    50674      -22     
  Partials     1765     1765              
Flag Coverage Δ
javascript 69.60% <82.85%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jun 27, 2026
@bito-code-review

bito-code-review Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #80e280

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 1e74f1b..fb03f75
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@sadpandajoe

Copy link
Copy Markdown
Member

@rusackas It seems like we are missing regression coverage for the two failure paths you added in embedded/index.tsx and menu.tsx.

A targeted Jest test should force setupPlugins()/setupCodeOverrides() to reject, resend guestToken, and assert plugin setup is retried and render/user bootstrap can proceed. Another small test should cover menu rendering after initPreamble() rejects and logging when import/render fails.

Comment thread superset-frontend/src/embedded/index.tsx
@netlify

netlify Bot commented Jul 3, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 80b40fe
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a4add3f14311800084e1a75
😎 Deploy Preview https://deploy-preview-41491--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@bito-code-review

bito-code-review Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #573ee4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: fb03f75..cdd1588
    • superset-frontend/src/embedded/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

rusackas and others added 3 commits July 5, 2026 15:38
Adds a rejection handler to the pluginsReady promise chain in the embedded
start() so a throw from setupPlugins() or setupCodeOverrides() resets the
started guard and logs the error, preventing embedded dashboards from getting
stuck in a failed state. Aligns the empty .catch in menu.tsx with the
try/finally + logging.error pattern used in views/index.tsx.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A transient failure loading or running the plugin setup left the
module-level pluginsReady promise permanently rejected, so resetting the
started guard alone could not recover: a retry chained off the same
rejected promise. Recreate it on failure so a rehandshake actually
re-runs plugin initialization.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Attach a no-op rejection handler when (re)creating pluginsReady so a
rejection that settles before the next start() attaches its handler
doesn't surface as an unhandled-rejection warning. start() still handles
the rejection itself.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rusackas rusackas force-pushed the fix/followup-40729-follow-up-from-40729-fix-i18n-defer-plug branch from cdd1588 to 80b40fe Compare July 5, 2026 22:39
Add regression coverage for the two failure paths this PR touches: the
embedded start() guard resetting and recreating pluginsReady so a retry
re-runs plugin setup, and the menu still rendering (and logging) when
initPreamble() rejects or render throws.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rusackas

rusackas commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

@sadpandajoe Good call — added Jest coverage for both: index.test.tsx forces setupPlugins() to reject then re-handshakes and asserts the retry re-runs setup and the user bootstraps, and menu.test.tsx covers the menu still rendering after initPreamble() rejects plus the error log when render throws.

@bito-code-review

bito-code-review Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f8269e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 4 · Commit Range: e5f0ea5..2be68a4
    • superset-frontend/src/embedded/index.test.tsx
    • superset-frontend/src/embedded/index.tsx
    • superset-frontend/src/views/menu.test.tsx
    • superset-frontend/src/views/menu.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants