Skip to content

Fix library add/update hanging when the screenshot fails (#530) - #531

Merged
rahulwalunje merged 2 commits into
mainfrom
issues/530-library-screenshot-hang
Nov 18, 2026
Merged

rahulwalunje merged 2 commits into
mainfrom
issues/530-library-screenshot-hang

Conversation

@rahulwalunje

@rahulwalunje rahulwalunje commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator
  • Fixes adding a page to a library hanging forever when the page has a background image offset from the right and bottom edges (right -43px bottom -53px): html2canvas-pro 2.6.3 now parses the calc() positions Chrome reports for these.
  • Fixes the Update dialog hanging when the screenshot fails: the item now updates without a screenshot.
  • Stops a failed screenshot from wiping the item's existing thumbnail, and from failing the whole request on the cloud side.

Fixes #530.

Depends on beaverbuilder/packages#178 (merged, published)

https://github.com/beaverbuilder/packages/pull/178 holds the other half (the add-to-library and import fallbacks live in @beaverbuilder/cloud-ui). It is merged and published as @beaverbuilder/cloud-ui 0.8.74, and this PR now requires ^0.8.74 (57e08e8).

package-lock.json is still generated with --legacy-peer-deps. The cloud-ui peer conflict is gone, but a plain npm install fails on an older one that main has too: @beaverbuilder/fluid-docs 0.0.6 declares @beaverbuilder/icons ^0.0.5, and the repo pins icons 0.0.10.

What changed

  • @beaverbuilder/cloud-ui 0.8.73 to 0.8.74: failed screenshots now reject instead of hanging, the add and import paths fall back to uploading without one, and it passes skipValidation, which html2canvas-pro 2.x needs for the image proxy.
  • html2canvas-pro 1.5.11 to 2.6.3: 1.x drops calc() tokens in background-position and crashes with Cannot read properties of undefined (reading 'type'). It is a peer dependency of cloud-ui, so assistant's copy is the one bundled into build/apps.js. The lockfile drops four 1.x-only dependencies. build/vendor-html2canvas.js is built from the same package and upgrades with it (about 10KB larger).
  • library-item/form/config/post.js (Update dialog): on a screenshot failure it logs and updates without one. A failed post lookup now shows the existing error notice and closes the dialog instead of leaving it on "Updating...".
  • LibraryItemPostController::get_save_data(): with no client screenshot it used to send the page HTML (ScreenshotHelper::get_for_url()). The cloud API turns that into a Browsershot screenshot, but Browsershot isn't in its composer.json, so the request failed after clearing the item's thumb. It now omits screenshot, and the cloud skips screenshots when the key is absent. Behavior with a client screenshot is unchanged.

The payload sent to the cloud can now lack the screenshot key; the cloud already handles that (CreateLibraryItemScreenshot returns early).

Testing

Done on a local site against the local cloud API, with the cloud-ui build from beaverbuilder/packages#178 in place of the published package. Test page: an HTML module with background:url(...) no-repeat right -43px bottom -53px.

Path Normal Screenshot forced to fail
Add to library Added, correct 1500x586 screenshot (hung before) "Added", failure logged, no cloud error
Update library item Updated, new screenshot "Library item updated!", failure logged, no cloud error, existing thumbnail kept
Add a page with a cross-origin image Added, image loads through the proxy not run

Retested on 2026-11-18 with the cloud-ui build from beaverbuilder/packages#178 and html2canvas-pro 2.6.3: all of the above pass. Not retested: importing an XML file into a library.

  • On 2026-11-07, new LibraryItemPostSaveDataTest (3 tests) passed and failed 2 of 3 on the old controller. Full PHPUnit suite: no new failures.
  • PHPCS and ESLint: no new findings in the changed files.

🤖 Generated with Claude Code

…ls (#530)

The library item Update dialog never settled when html2canvas rejected, so it now logs the failure and updates without a screenshot, and closes with an error notice if the post lookup fails.

Without a client screenshot, get_save_data() used to send the page HTML, which the cloud cannot screenshot (no Browsershot) and which clears the item's existing thumb. It now omits the screenshot, so the cloud skips it.

Upgrades html2canvas-pro to 2.6.3, which parses calc() background positions. The lockfile was generated with --legacy-peer-deps until @beaverbuilder/cloud-ui with the widened peer range is published.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@codente

codente commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Merge Check

State: tested at 57e08e8, lane ui, verdict Merge with follow-ups; next is one approving review. Lane ui recorded in the sticky only; this repo has not opted into the risk lanes (no risk: labels).

TLDR

Adding a page to a library, or updating a library item, no longer hangs when the page's screenshot fails, and a failed screenshot no longer wipes the item's existing thumbnail.

Review

merge-check fast review, round 2: Ship, the cloud-ui blocker is fixed at 57e08e8; 1 concern stands (no CI for PHP or lint).

Review detail

Blockers

  • package.json / package-lock.json: html2canvas-pro 2.6.3 ships without the cloud-ui 0.8.74 it depends on. Fixed in 57e08e8, verified against the diff: @beaverbuilder/cloud-ui is ^0.8.74, and the lockfile resolves cloud-ui-0.8.74.tgz with peer html2canvas-pro ^1.5.8 || ^2.6.3. Those two files are the commit's only changes. 0.8.74 is on npm (beaverbuilder/packages#178 merged as 69eaa29). The lockfile is still generated with --legacy-peer-deps, but that is not this PR's: main's own package.json fails a plain install too (ERESOLVE on @beaverbuilder/cloud 0.5.30's axios ^0.22.0 peer), and at this head the remaining conflict is fluid-docs 0.0.6 vs icons 0.0.10, both pinned the same on main.

Concerns

  • No CI runs PHPUnit, PHPCS or ESLint on this repo (only label_issue); the body's test and lint claims are local and unverified here. The executor's run should repeat LibraryItemPostSaveDataTest. Still open: the author's 2026-11-18 note says it has not been rerun at this head.

Verified: get_save_data() omitting screenshot matches the cloud — assistant-cloud-api/app/Traits/CreateLibraryItemScreenshot.php calls Browsershot::html() and Browsershot is not in that repo's composer.json. post.js findById catch mirrors doRequest's finally (notice, setUpdating( false ), closeDialog()).


fast review · 6 files / +208/-72 lines reviewed.

Sanity check

High depth (UI), adversarial pass: right approach; nothing hard to reverse, no decision needed. Follow-up worth filing: screenshotUrl() has no timeout, so an html2canvas stall that never rejects can still hang.

Sanity check detail

Lane: ui — Update dialog behavior and its error notice on a failed post lookup; add-to-library and update outcomes a person sees. No irreversible trigger: no stored shape, hook, signature or REST shape changes; the cloud payload only loses an optional key. html2canvas-pro 1.x to 2.x is an upgrade of an existing dependency, not a new one.

  • Omitting screenshot is safe on both callers (save_to_library and sync_to_library in LibraryItemPostController.php): the cloud trait returns before clearMediaCollection when the key is absent. Only a cloud older than the Laravel 11 conversion (July 2024, which dropped Browsershot) would lose server-side thumbs; worth confirming production is newer, not blocking.
  • html2canvas-pro 2.6.3 ships ?. untranspiled (webpack.config.js excludes node_modules from Babel): needs roughly Chrome 80 / Safari 13.1, fine for wp-admin. window.HTML2Canvas keeps its shape; bundle about 10KB larger.
  • skipValidation: true skips html2canvas 2.x's element and options validators; sound here, since the proxy is the plugin's own same-origin endpoint and the element is always body.
  • UX: a failed screenshot on update keeps the old thumbnail with only a console.error, no notice. Better than the old wiped thumb or 500; silent.

Merge context

Overlaps: #519 also edits get_save_data()'s screenshot line (it adds $with_screenshot and sends null for companions); whichever lands second needs a hand rebase that keeps "omit the key" for companions. #532 edits package.json and the lockfile; rebase its lockfile surgically if #531 lands first.

Test results

All 7 test-plan steps pass at 57e08e8 with the published cloud-ui 0.8.74: LibraryItemPostSaveDataTest 3 of 3, add / update / XML import each pass both normally and with the screenshot forced to fail (the failed ones save without a screenshot and keep the old thumbnail), and the sweep shows no console errors. Follow-ups: the screenshotUrl() timeout above, and the #519 rebase.

Test evidence

Local site (Local, PHP 7.4 for PHPUnit) and the local cloud API, plugin at 57e08e8 built with npm ci --legacy-peer-deps && npm run build; build/apps.js confirmed to contain skipValidation and the 2.x parser. Captures stayed local, not attached.

  • PHPUnit --filter LibraryItemPostSaveDataTest: OK (3 tests, 4 assertions).
  • ESLint on post.js: 9 errors at head, the same 9 on main; none new.
  • Add calc() page: Added, cloud item 20 with a 1500x584 screenshot, byte-identical to the one checked by eye earlier today.
  • Add page with a cross-origin Unsplash hero: Added, item 21, 1500x7932, hero image present in the screenshot.
  • Add with toDataURL forced to throw: Added, console Screenshot failed, uploading without one., no iframe left, item 22 has no media, no cloud error.
  • Update with the forced failure: Library item updated!, console Screenshot failed, updating without one., item 20 kept media 15. No tab freeze with the lighter patch.
  • Normal update: Library item updated!, item 20 media 15 replaced by 17.
  • XML import (WXR of the calc() page, same site): item 23 with a screenshot; again with the forced failure: item 24 with no media, console fallback logged. Laravel log: 0 errors in the run window.
  • Sweep: reload, Media app, Libraries app: no console errors. One 503 from system.js appeared once during a double page navigation before the first add; not reproduced, not in a changed path.

Test plan

  1. On a site running this branch (build with the published cloud-ui 0.8.74), open a page whose HTML module has background:url(...) no-repeat right -43px bottom -53px and add it to a library: it is added with a correct screenshot.
  2. Add a page with a cross-origin image: added, the image renders in the thumbnail.
  3. Update that library item from its page: "Library item updated!" and a new thumbnail.
  4. Force the screenshot to fail (see the playbook) and add a page: "Added", no spinner left, the item has no thumbnail.
  5. Force the failure again and update an item: "Library item updated!", the existing thumbnail is kept.
  6. Import an XML export containing a post with that background into a library: the import finishes.
  7. Run LibraryItemPostSaveDataTest: 3 of 3 pass.
Agent playbook

Preconditions: WordPress site with the Assistant plugin on branch issues/530-library-screenshot-hang at 57e08e8, npm ci --legacy-peer-deps && npm run build run in the plugin (installs cloud-ui 0.8.74 from npm; confirm node_modules/@beaverbuilder/cloud-ui/package.json says 0.8.74 and build/apps.js contains skipValidation). Assistant connected to a cloud account with at least one library. A test page whose HTML module has background:url(<image>) no-repeat right -43px bottom -53px, and a page with an <img> from another origin. Browser-tools tab enabled on the site, logged in as an admin.

  1. Unit tests: composer tests -- --filter LibraryItemPostSaveDataTest (PHPUnit 7.5 on PHP 7.4, with a WP test DB per backend/tests/README.md). Expect 3 of 3 pass.
  2. npm test (ESLint over src). Expect no new findings in src/apps/libraries/ui/library-item/form/config/post.js.
  3. Navigate to the calc() test page, open the Assistant panel (click the floating Assistant button), open Libraries, open the library, click the + (Add Items) button, search the page title, click its Add. Expect the link text to change to Added within 15s and the console to show html2canvas Finished rendering with no error. The new library item's thumbnail shows the image anchored bottom-right.
    capture: the library grid showing the new item's thumbnail
  4. Same flow for the cross-origin image page. Expect Added and the image present in the thumbnail.
  5. Force failure: /eval in the page and in every iframe it creates, replacing HTMLCanvasElement.prototype.toDataURL with a function that throws (patch iframe.contentWindow on insertion; a top-window patch alone misses). Add a third page. Expect Added, console error Screenshot failed, uploading without one., no iframe left in the DOM, and the cloud item saved with no thumb media.
  6. With the patch still on, open an existing library item, click Update, confirm Update in the dialog. Expect the notice Library item updated!, console error Screenshot failed, updating without one., and the item's thumbnail unchanged. Note: the patch can freeze the tab for a minute or two before the request goes out; that is the patch, not the PR.
    capture: the item view with the Library item updated! notice and the old thumbnail
  7. Reload without the patch, open the same item, Update again. Expect Library item updated! and a new thumbnail within a few seconds.
  8. Import: in the library's Add Items, use the XML import with an export containing a post that has the calc() background. Expect the import to finish and the last item to appear.
  9. Nothing-else-broke sweep: open Libraries, a library, and a library item; open the Media app; reload. Expect no console errors from apps.js other than the forced ones above.
    capture: the Libraries app after reload
Run history
When (UTC) Head State Delta
2026-11-18 57e08e8 tested local run at 57e08e8: 7 of 7 test-plan steps pass (PHPUnit 3/3, ESLint none new, add/update/import normal and forced-failure, sweep); verdict Merge with follow-ups; no merge: labels in this repo, none written
2026-11-18 57e08e8 ready review round 2: blocker fixed by the cloud-ui ^0.8.74 bump (0.8.74 published, packages#178 merged); --legacy-peer-deps shown pre-existing on main; high-depth sanity pass clean (timeout follow-up noted); overlaps #519, #532; lane ui, marker-only, no merge: labels in this repo
2026-11-09 a9cb6c9 changes-requested first run: fast review, 1 blocker (cloud-ui 0.8.74 bump missing); lane ui classified (Update dialog error notice), marker-only; no merge: labels in this repo, none written

bb-merge-check · head:57e08e8 · state:tested · risk:ui

0.8.74 rejects failed screenshots instead of hanging and passes skipValidation, which html2canvas-pro 2.x needs for the image proxy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rahulwalunje

Copy link
Copy Markdown
Collaborator Author

Merge check blocker resolved; ready for another merge check at 57e08e8.

  • cloud-ui bump (the blocker): beaverbuilder/packages#178 is merged and @beaverbuilder/cloud-ui 0.8.74 is published to npm. 57e08e8 bumps this PR to ^0.8.74. The lockfile change is only cloud-ui 0.8.74 and its wider html2canvas-pro ^1.5.8 || ^2.6.3 peer range. The rebuilt build/apps.js contains skipValidation.
  • --legacy-peer-deps: the cloud-ui peer conflict is gone, but a plain npm install still fails on an older conflict that main has too: @beaverbuilder/fluid-docs 0.0.6 declares @beaverbuilder/icons ^0.0.5, and the repo pins icons 0.0.10. That is out of scope here, so the lockfile is still generated with --legacy-peer-deps.
  • Retest on 2026-11-18 (local site + local cloud API, cloud-ui build from packages#178, html2canvas-pro 2.6.3):
    • Add the calc() background page: added, correct 1500x584 screenshot.
    • Add a page with a cross-origin image: added, image loads through the proxy.
    • Add with the screenshot forced to fail: "Added", fallback logged, saved without a screenshot.
    • Update with the screenshot forced to fail: "Library item updated!", fallback logged, existing thumbnail kept.
    • Normal update: new screenshot replaces the thumbnail.
    • Not retested: importing an XML file into a library.
  • Concern (no CI for PHPUnit / PHPCS / ESLint): still true for this repo. LibraryItemPostSaveDataTest passed locally on 2026-11-07 but has not been rerun at this head; the executor's run should repeat it.

@rahulwalunje
rahulwalunje merged commit 133b68f into main Nov 18, 2026
2 checks passed
@rahulwalunje rahulwalunje mentioned this pull request Nov 19, 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.

Adding a page to a library hangs when a background image is offset from the right and bottom edges

3 participants