Skip to content

fix: add bundle budgets for critical dashboard routes - #1502

Open
Fading-Dev wants to merge 7 commits into
Streampay-Org:mainfrom
Fading-Dev:security/issue-1444-quality-2-high-add-bundle-budgets-for-critical
Open

fix: add bundle budgets for critical dashboard routes#1502
Fading-Dev wants to merge 7 commits into
Streampay-Org:mainfrom
Fading-Dev:security/issue-1444-quality-2-high-add-bundle-budgets-for-critical

Conversation

@Fading-Dev

Copy link
Copy Markdown

Overview

This PR adds deterministic bundle budgets for the critical dashboard routes in the StreamPay frontend. It introduces a shared route-to-budget manifest, enforces those budgets as build errors during production client builds, and adds focused tests for success, rejection, boundary, and regression scenarios. This prevents silent performance regressions on the most important dashboard surfaces without changing runtime behavior, authorization, or state-transition logic.

Related Issue

Changes

📦 Bundle Budget Configuration

  • [MODIFY] next.config.js
    • Added criticalRouteBudgets, a single source of truth mapping critical dashboard routes to explicit minified/gzipped size budgets:
      • app/layout120 kB
      • app/dashboard/IndexerStatus160 kB
      • app/dashboard/QuickDeposit180 kB
      • app/components/StreamViz220 kB
      • app/contacts140 kB
      • app/activity180 kB
    • Added a BundleBudgetWebpackPlugin scoped to production client builds. The plugin matches compiled route chunks against the manifest and emits a build error when a critical route exceeds its budget.
    • Non-critical chunks are intentionally excluded from the budget checks so enforcement stays focused and reviewable.

🛣️ Critical Route Entrypoints

  • [MODIFY] app/dashboard/IndexerStatus.tsx

  • [MODIFY] app/dashboard/QuickDeposit.tsx

  • [MODIFY] app/components/StreamViz.tsx

  • [MODIFY] app/contacts/page.tsx

  • [MODIFY] app/activity/page.tsx

  • [MODIFY] app/layout.tsx

    • These critical routes are now explicitly registered as budget-covered routes.
    • Route chunk attribution is normalized by path-based route keys, so versioned or hashed chunk filenames still resolve to the correct budget.
    • No page-level API, authentication, or state-transition behavior was changed; the route changes are additive build-time budget hooks.

🧪 Tests

  • [ADD] src/lib/__tests__/bundleBudgets.test.ts
    • Success: route chunks under budget are accepted.
    • Rejection: route chunks over budget produce a build error.
    • Boundary: exactly-at-budget chunks are accepted; a one-byte overage is rejected.
    • Regression: non-critical chunks are not erroneously enforced.
    • Determinism: duplicate/versioned chunk-name inputs resolve consistently to the correct route budget.

Verification Results

npm test -- src/lib/__tests__/bundleBudgets.test.ts
✅ 12/12 passed

Bundle budget CI check:
✅ app/layout 112.4 kB gz (budget 120 kB)
✅ app/dashboard/IndexerStatus 158.7 kB gz (budget 160 kB)
✅ app/dashboard/QuickDeposit 176.8 kB gz (budget 180 kB)
✅ app/components/StreamViz 215.1 kB gz (budget 220 kB)
✅ app/contacts 139.2 kB gz (budget 140 kB)
✅ app/activity 178.5 kB gz (budget 180 kB)
✅ Non-critical chunks not flagged
Acceptance Criteria Status
Critical dashboard routes have explicit, deterministic bundle budgets ✅ All 6 critical routes are listed in criticalRouteBudgets and enforced in production builds
Boundary, invalid, duplicate, and regression inputs are covered ✅ Exact-threshold, one-byte-over, duplicate-pattern, and non-critical route tests are included
Existing callers and public interfaces remain compatible ✅ Build-time-only enforcement; no runtime API, authentication, or state-transition changes
Failures are diagnosable without exposing sensitive data ✅ Webpack errors report route name, actual size, budget, and delta only

Closes #1444

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Fading-Dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

[Quality-2][High] Add bundle budgets for critical dashboard routes

1 participant