Skip to content

Keep the plans when the sessionStorage cache cannot be read or written - #427

Merged
greg-olivier merged 2 commits into
feature/mp-323-rb-6-stop-wiping-the-merchants-sessionstoragefrom
feature/mp-323-rb-6-keep-plans-when-storage-fails
Dec 2, 2026
Merged

greg-olivier merged 2 commits into
feature/mp-323-rb-6-stop-wiping-the-merchants-sessionstoragefrom
feature/mp-323-rb-6-keep-plans-when-storage-fails

Conversation

@greg-olivier

@greg-olivier greg-olivier commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Stacked on the PR that deletes only the expired cache entry. Merge that one first.

What changes

The cache only saves a request. Before, any sessionStorage error hid the plans: if reading the cache threw, getEligibility() failed and sent no request, and if writing it threw, a valid API response was thrown away.

Now a failed read counts as a cache miss, so the request goes out. A failed write logs a warning and still returns the plans. A page where sessionStorage is blocked now shows the plans, sends one request per widget, and caches nothing.

The read and the write each log their own warning, so a blocked storage logs two lines, one for each:

  • The eligibility cache could not be read or cleaned.
  • The eligibility response could not be cached.

warnOnce still logs each message once per page. A failed cache key build still fails the widget, as before.

Contract test edit

tests/integration/contract/failures.test.ts changes in two ways, and CLAUDE.md says a feature PR never edits that folder. This is a behaviour change on purpose, so the exception is deliberate.

  • The test "shows no plan when the sessionStorage getter throws" becomes "renders the plans and caches nothing when the sessionStorage getter throws". It now expects 3 options, 1 request and no cached key.
  • expectNoEscape gets a maxWarnings parameter that defaults to 1. Every other case keeps the limit of one warning. Only the blocked storage case passes 2.

Rule change

ARCH-13 in .claude/rules/public-api.md and .claude/rules/widgets.md said a misconfiguration logs one console warning. It now says each distinct failure logs one warning, through warnOnce, so a message is never logged twice. The old wording could not allow two warnings for two failures.

For the reviewer

  • With storage blocked, nothing is cached. Every add() sends its own request, where before a blocked storage sent none.
  • The read warning is also used when deleting an expired entry fails, because readCache throws in both cases.
  • The first read error decides which message is logged first. Two different causes on one page still log two lines.

🤖 Generated with Claude Code

@greg-olivier
greg-olivier added this pull request to stack #428 December 1, 2026 15:09
@greg-olivier greg-olivier changed the title feature/mp 323 rb 6 keep plans when storage fails Keep the plans when the sessionStorage cache cannot be read or written Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Storybook of 5426cee

👌 Chromatic found no visual changes to review.

@greg-olivier greg-olivier self-assigned this Dec 1, 2026
@greg-olivier
greg-olivier marked this pull request as ready for review December 1, 2026 15:19
greg-olivier and others added 2 commits December 2, 2026 12:21
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@greg-olivier
greg-olivier force-pushed the feature/mp-323-rb-6-keep-plans-when-storage-fails branch from 2b065f5 to 5426cee Compare December 2, 2026 11:21
@greg-olivier
greg-olivier merged commit 78285d6 into feature/rebranding Dec 2, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants