🍕 Document value-shaped state pattern beyond sticky events - #261
Merged
Merged
Conversation
Adds a new section to CLAY-VITE.md, "Beyond sticky events: value-shaped state for cross-cutting client facts", immediately after the existing Sticky Events section. It generalizes the ESM dynamic-import race beyond stickyEvents' narrow event-replay coverage: a one-shot signal (event, or vendor-assigned callback slot) fired before interested code has subscribed is lost for that pageview. Uses the OneTrust/OptanonWrapper production incident as a worked example, explains precisely why stickyEvents can't help with a third-party vendor callback slot (and is edge-shaped even where it does apply), and documents the recommended value-shaped store pattern (get/set/subscribe, with an inline synchronous script owning the vendor callback slot) as guidance for consuming-site code — not a claycli API. Explicitly rules out eager/static component imports as a substitute fix, notes claycli's own role is this guidance plus an existing build-time window.<Identifier> diagnostic, and frames stickyEvents as a bridge that migrated events can eventually drop. Also adds one QA checklist item confirming no component's client.js depends on winning a race against a third-party vendor callback or another component's one-shot signal. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR — for reviewers short on time
CLAY-VITE.mdsection generalizing a real production bug (a vendor consent-management callback answered by a stale no-op because Vite's deferred bootstrap runs it too late) into the underlying pattern: Vite's async bootstrap removed the total execution order Browserify gave every site for free, andstickyEventsonly covers one narrow instance of the resulting race class. Documents a value-shaped store pattern (get/set/subscribe, subscribe fires immediately with the current value) as the fix for any cross-cutting client fact — explicitly framed as a pattern for site code, not a claycli API. No code changes..jsfile touched.stickyEvents(generate-bootstrap.js) and the bootstrap timing it describes; matches the doc's existing voice and heading structure (placed as a sibling deep-dive alongside "Sticky events" and "Watch mode" under Section 8).CLAY-VITE.mdL1018–L1032 — "WhystickyEventsdoesn't reach this": the section's most important claim, and the one most likely to be second-guessed. It doesn't overstate whatstickyEventsdoes — it precisely scopes what it can't reach (a third-party vendor callback slot) and why (nothing in claycli's bootstrap is anywhere near that call path).CLAY-VITE.mdL965–L989 — the general race shape (one-shot signal fired before the interested code can subscribe), named beyond just the worked example: vendor callbacks, one-shotMutationObservers, uncovered custom events.CLAY-VITE.mdL991–L1016 — the worked example (OptanonWrapperanswered by the page's own inline no-op) grounding the general shape in a real incident.CLAY-VITE.mdL1034–L1070 — the value-shaped store pattern (illustrative pseudocode, explicitly labeled as site-code, not claycli API).CLAY-VITE.mdL1072–L1107 — the companion boundary-adapter pattern, and why it must be a synchronous inline script.CLAY-VITE.mdL1109–L1132 — explicitly rules out "run component imports eagerly" as a substitute fix, and framesstickyEventsas a bridge rather than deprecating it outright.Feature Info
Description
Generalizes a fixed incident (a vendor consent callback race) into documented guidance for the whole class of bug, so the next vendor integration or cross-component signal has a pattern to reach for instead of reinventing a per-file catch-up fix. Companion to the code-level fixes landing in the other three PRs from this pass (#258, #259, #260).
🤖 Generated with Claude Code