Skip to content

chore: remove unshipped anywidget init-timeout workaround - #422

Draft
cpsievert wants to merge 5 commits into
mainfrom
chore/drop-anywidget-timeout-patch
Draft

cpsievert wants to merge 5 commits into
mainfrom
chore/drop-anywidget-timeout-patch

Conversation

@cpsievert

@cpsievert cpsievert commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Why

PR #335 added relax_anywidget_init_timeout(), which served a regex-patched
copy of anywidget's front-end with its hard-coded 2s model-init budget raised
to 60s. That workaround never shipped in a release (last release v0.8.2
predates #335), and the upstream fix — manzt/anywidget#1032, removing the
timeout and the comm-message gate entirely — makes it permanently unnecessary.

So: remove it now and count on the upstream fix, rather than ship a workaround
we'd immediately want to delete. Relative to v0.8.2 this changes nothing a
user could observe, so there's no changelog entry.

What changed

  • Deleted relax_anywidget_init_timeout, its call site in
    require_dependencies(), the cache dict, and ANYWIDGET_INIT_TIMEOUT_MS
    from shinywidgets/_dependencies.py (-69 lines).
  • Deleted the two dedicated unit tests and ANYWIDGET_INDEX_JS fixture from
    tests/unit/test_dependencies.py (-41 lines).
  • Marked the Playwright tests for large-bundle anywidgets — keplergl (~13MB
    inline _esm), lonboard, and plotly — xfail(strict=False) while the
    installed anywidget is <0.11.1 (ANYWIDGET_INIT_XFAIL in
    tests/playwright/conftest.py). Without the patch, these bundles can trip
    anywidget's 2s model-init budget under CI-grade CPU contention and
    permanently desync (all three failed exactly that way on the first CI run
    of this branch). The mark lifts itself automatically once CI installs an
    anywidget release containing fix: remove ready gate on comm messages to prevent permanent desync manzt/anywidget#1032 — no follow-up needed to
    re-enable full-strength testing.
  • No pyproject.toml anywidget floor. Fresh installs (including CI) get the
    fixed anywidget automatically once it's released; environments pinned to
    older anywidget return to the pre-fix: keplergl Playwright CI failures from anywidget init races #335 status quo they always had.

Not touched: the js/src/keplergl.ts height re-assertion from #335 — that's
an independent keplergl race (missed change:height sync), still needed.

Also in this PR: exclude perspective-python 5.7.0

Unrelated to the anywidget change, but it broke CI on this branch and will
break main on its next run (CI resolves fresh; uv.lock is gitignored):
perspective-python 5.7.0 (released 2026-11-05, with a "Better WASM init"
change) logs viewer wasm is already initialized and functionally breaks
second-viewer initialization and re-rendering — viewers never display data.
Reproduced locally: tests/playwright/render_perspective passes 6/6 in ~9s
on 5.6.1, while on 5.7.0 two tests time out waiting for data. The
!=5.7.0 exclusion covers the perspective extra and the test/dev
dependency sets. Should be reported upstream (perspective-dev/perspective).

Testing

Unit suite green (968 passed). Full CI green: py-test 3.11–3.15 and all 4
Playwright shards. The ANYWIDGET_INIT_XFAIL mark verified to apply to all
keplergl, lonboard, and plotly Playwright tests under anywidget 0.11.0, and
to lift on >=0.11.1.

…ing on it

PR #335 served a regex-patched copy of anywidget's nbextension index.js
with the hard-coded 2s model-init budget (AbortSignal.timeout(2e3))
raised to 60s, working around manzt/anywidget#1030 (slow-loading
widgets permanently desyncing). Upstream is removing the timeout and
the `ready` gate entirely, so serve anywidget's files unmodified and
drop the patch, its cache, and its tests.
Without the init-timeout patch (removed in the previous commit) and
before the upstream fix ships (manzt/anywidget#1032), keplergl's ~13MB
inline _esm can trip anywidget's 2s model-init budget under CI-grade CPU
contention, permanently desyncing the widget. Non-strict xfail keeps the
suite green without hiding passes, and the mark lifts itself once CI
installs anywidget 0.11.1.
lonboard also inlines a multi-MB _esm (its own copy of luma.gl/deck.gl)
and failed in CI with the same permanent-desync console errors as
keplergl. Rename the mark to ANYWIDGET_INIT_XFAIL since it's no longer
keplergl-specific.

The perspective failures in the same runs are a different issue: their
shards logged no 'Failed to initialize model' errors, so the 2s timeout
never fired and the patch removal couldn't have affected them. Their
functional assertions passed; only the strict console-error check
tripped on perspective's benign page-global 'viewer wasm is already
initialized' message.
@cpsievert
cpsievert force-pushed the chore/drop-anywidget-timeout-patch branch from 8ff6bae to ebe548b Compare November 6, 2026 18:08
perspective-python 5.7.0 (released 2026-11-05, includes a 'Better WASM
init' change) logs 'viewer wasm is already initialized' and functionally
breaks second-viewer initialization and re-rendering: viewers never
display data. Reproduced locally: tests/playwright/render_perspective
passes 6/6 in ~9s on 5.6.1; on 5.7.0 two tests time out waiting for data
and the rest log the wasm error. Unrelated to the anywidget change in
this PR -- CI resolves fresh (uv.lock is gitignored), so main would hit
this on its next run too.
plotly's FigureWidget is anywidget-based with a multi-MB inline _esm
(plotly.js), and plotly_accessors failed in CI with the same
permanent-desync console errors as keplergl and lonboard. Mark all
plotly test modules with ANYWIDGET_INIT_XFAIL.
@cpsievert
cpsievert force-pushed the chore/drop-anywidget-timeout-patch branch from 5337e50 to abf0e60 Compare November 6, 2026 18:29
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.

1 participant