Skip to content

Narrow PR scope to observer tick error isolation; restore synchronous initial render - #371

Closed
mattcosta7 with Copilot wants to merge 2 commits into
copilot/optimize-relative-time-updatefrom
copilot/copilotoptimize-relative-time-update-again
Closed

mattcosta7 with Copilot wants to merge 2 commits into
copilot/optimize-relative-time-updatefrom
copilot/copilotoptimize-relative-time-update-again

Conversation

Copilot AI commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

This revision removes the previously introduced connectedCallback microtask batching and keeps only the high-value safety fix: a single element error should not abort a dateObserver tick for all observed elements. It also drops per-tick locale/time-zone/hour-cycle caching from this branch to avoid correctness risk and overlap with existing global Intl caching.

  • Scope reset: restore main lifecycle semantics

    • Removed module-level pending render queue (pendingElements, pendingFlush, flushPending).
    • Restored synchronous connectedCallback() render (this.update()).
    • Restored disconnectedCallback() and attributeChangedCallback() behavior to match main (no pending-queue coupling).
  • Observer robustness: per-element error isolation

    • Guarded each timeEl.update() inside dateObserver.update() so one throw does not stop remaining elements or prevent rescheduling.
    • Preserved global error visibility by rethrowing asynchronously.
  • Tests updated to lock intended behavior

    • Removed the full connectedCallback microtask batching suite.
    • Added synchronous-render contract coverage (text/title present immediately after append).
    • Added error-isolation coverage demonstrating other elements continue updating and observer scheduling continues when one element throws.
for (const timeEl of this.elements) {
  nearestDistance = Math.min(nearestDistance, getUnitFactor(timeEl))
  try {
    timeEl.update()
  } catch (error) {
    setTimeout(() => {
      throw error
    })
  }
}

Copilot AI changed the title [WIP] Remove memoization cache from relative time update Narrow PR scope to observer tick error isolation; restore synchronous initial render Jul 30, 2026
Copilot AI requested a review from mattcosta7 July 30, 2026 16:16
@mattcosta7

Copy link
Copy Markdown
Member

Superseded by #399, which isolates errors per element during a shared-timer tick on top of #396. It also covers getUnitFactor (a throwing date getter, or an invalid time-zone on an element an hour or more old), which ran outside this PR's try. It checks that each error is reported exactly once, and it's based on current main instead of a branch 61 commits behind.

@mattcosta7 mattcosta7 closed this Nov 9, 2026
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.

2 participants