fix(maintenance): extract bypass cookie config into shared module - #885
fix(maintenance): extract bypass cookie config into shared module#885Rafiat30 wants to merge 5 commits into
Conversation
|
@Rafiat30 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! 🚀 |
|
Auto-review failed (API error). Leaving PR for human review. |
1 similar comment
|
Auto-review failed (API error). Leaving PR for human review. |
|
clean fix: moving one non-blocking note:
gate: branch is behind main; please update/rebase and let CI rerun, then this is good to go. |
Move MAINTENANCE_COOKIE and BYPASS_COOKIE_MAX_AGE out of middleware.ts into src/lib/maintenanceConfig.ts so the client-side MaintenanceBypass component no longer imports from an Edge-runtime middleware file. Behavior is unchanged: the bypass cookie already applied max-age from BYPASS_COOKIE_MAX_AGE, this just fixes the import graph. Refs Iris-IV#556
Adds regression coverage for the maintenanceConfig.ts extraction: locks the 24h BYPASS_COOKIE_MAX_AGE and MAINTENANCE_COOKIE values, verifies the exact cookie string MaintenanceBypass.tsx builds embeds max-age from the shared constant, and covers the no-wallet-connected render path. Refs Iris-IV#556
buildBypassCookie duplicated the cookie string MaintenanceBypass.tsx builds, so those assertions verified the test helper rather than the component. The rendered-component tests below already cover the real behavior.
f87e211 to
a2a20a1
Compare
|
Auto-review failed (API error). Leaving PR for human review. |
- Format useMultiSigProposals.test.tsx (Prettier check was failing on it) - Add missing Causes.listView/mapView translation keys (en, es) — the view-toggle buttons on /causes reference these keys but they were never added, so next-intl throws MISSING_MESSAGE and the Playwright smoke test fails when it navigates through that page - Add the missing getAllCampaigns mock to the AppPageComponents contractClient mock, and cover the two HomeClient stats/CTA branches that were never exercised as a result (queryFn was undefined, so the stats panel and the wallet-connecting CTA state never rendered) None of this is related to this branch's actual change; main's CI was already failing on all three checks before this branch rebased onto it.
|
Auto-review failed (API error). Leaving PR for human review. |
|
@davidmaronio pls help review. i have fixed every issue |
|
this is verified and approved, but today's merge wave put the branch into conflict before it reached the front of the queue (lots of prs touching the same i18n and test files landed at once). please rebase onto current main and push, i'll merge as soon as it's green, no re-review needed. |
|
Auto-review failed (API error). Leaving PR for human review. |
|
the red checks were the pre-existing main breakage (sharebuttons lint, multisig test types), not your change. #867 just landed with the main fixes, so please rebase onto current main and this should go green, then i'll merge. |
Closes #556
Summary
BYPASS_COOKIE_MAX_AGEwas defined and exported frommiddleware.tsand was already being applied asmax-agewhenMaintenanceBypass.tsxsets the maintenance bypass cookie viadocument.cookie. The remaining issue was architectural: a client component was importing constants from an Edge-runtime middleware file.Changes
src/lib/maintenanceConfig.ts— sharedMAINTENANCE_COOKIEandBYPASS_COOKIE_MAX_AGEconstants.src/middleware.ts— imports the constants from the new shared module instead of defining/exporting them locally.src/components/MaintenanceBypass.tsx— imports the constants from@/lib/maintenanceConfiginstead of@/middleware.Why
Client components importing from
middleware.tsrisk pulling Edge/Next.js-server-only code into the client bundle. Moving the shared constants into a plain module used by both sides removes that coupling without changing runtime behavior — the cookie already carried the correctmax-age.How to test
NEXT_PUBLIC_MAINTENANCE_MODE=trueandNEXT_PUBLIC_MAINTENANCE_ALLOWLIST=<your wallet address>in.env.local.document.cookiein devtools —maintenance_bypassshould havemax-age=86400.npm run typecheckandnpm testpass.