Skip to content

fix(record-bin): stop blocking on toasts and show failures as errors - #172

Merged
roger-datocms merged 5 commits into
masterfrom
fix/record-bin-notice-without-wait
Nov 3, 2026
Merged

roger-datocms merged 5 commits into
masterfrom
fix/record-bin-notice-without-wait

Conversation

@roger-datocms

@roger-datocms roger-datocms commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

(Claude here [Opus 5.5])

Toast fixes from #152. It's independent of #171.

Problem

The plugin SDK has two toasts, and they behave differently. I measured both in a sandbox with a probe plugin:

Colour Closes by itself Promise resolves
ctx.notice() green (success) after ~6 s when it closes (6.0 s)
ctx.alert() red (error) never only when the user clicks the X

Record Bin awaited toasts in several flows, so those flows stalled:

  • Blocked deletions: onBeforeItemsDestroy awaited a green notice. That covers "could not verify a complete archive" and the over-200-records guard. The hook stayed open about 6 s after deciding, and the CMS reported Record Bin as slow ("taking longer then usual… onBeforeItemsDestroy").
  • Failed restores: "Restore record" stayed disabled until the user closed the red alert. The finally that resets loading and the in-progress lock ran only after the awaited alert.
  • Restore with failed archive cleanup: the plugin waited for the user to close the alert before opening the restored record.
  • Settings: "Save" stayed busy after a failed save until the alert closed, and so did "Disconnect" after a failed disconnect. A webhook cleanup failure showed a green notice and held a successful save for about 6 s.

Fix

  • Blocked deletions and the webhook cleanup failure now use ctx.alert(), the error toast. Elsewhere, the plugin already uses it for failures.
  • None of these flows await a toast anymore. alertFn in BinOutlet is now fire-and-forget, like noticeFn.
  • The delete hook still awaits all its CMA work. A genuinely slow capture still triggers the CMS warning.
  • Backup notice (new): deleting now shows "Record Bin is saving a copy of this record before it is deleted. This takes a few seconds." right away. For several records it says "…saving copies of N records…". It's fired, not awaited, like the alerts above. It closes on page change, because a successful delete leaves the record, or after 15 s.

Tests

  • Delete hook: three tests mock a toast that never settles: capture and the backup notice in lambdaLessCapture.test.ts, and the over-200 guard in index.test.tsx.
  • Restore: a new BinOutlet.test.tsx covers the Lambda-less restore flow, with an alert that never settles. A failed restore must finish, and a restore with failed cleanup must still open the record. This exports executeRestoreWithoutLambda for the test.
  • All four new tests time out without the fix.
  • The ConfigScreen changes have no unit tests. Testing its handlers needs a DOM test setup, which the plugin doesn't have.

npm test (107 tests; 108 combined with #171) and tsc --noEmit pass in record-bin. Biome reports one error, a format error in recordBinModel.test.ts that is already on master.

Sandbox results

Flow master This branch
Blocked deletion Green toast, hook returns at 7.7 s, slow-plugin warning at 5.6 s Red toast, hook returns at 1.6 s, no warning
Failed restore "Restore record" disabled until the alert is closed (still disabled at 15 s) Re-enabled at 1.1 s, with the alert
Any deletion No feedback during the few-second backup "Saving a copy" notice at 0.1 s; still no slow-plugin warning

Blocked deletion, about 6 s after confirming. Before: a green toast and the slow-plugin warning.

before-slow-plugin-warning

After: only a red error toast.

after-error-toast-only

Failed restore, 15 s after clicking with the alert still open. Before: "Restore record" is still disabled.

before-restore-button-locked

After: the button is ready for a retry.

after-restore-button-ready

Narrated before/after walkthrough of #171 + #172 in a legacy-flag sandbox (captions below the video):

record-bin-171-172-walkthrough.mp4

🤖 Generated with Claude Code

@roger-datocms roger-datocms changed the title fix(record-bin): return from onBeforeItemsDestroy without awaiting notices fix(record-bin): show blocked deletions as error toasts without awaiting them Oct 21, 2026
@roger-datocms roger-datocms changed the title fix(record-bin): show blocked deletions as error toasts without awaiting them fix(record-bin): stop blocking on toasts and show failures as errors Oct 21, 2026
roger-datocms and others added 4 commits November 3, 2026 13:01
…tices

The `ctx.notice()` promise settles when the toast closes, about six
seconds after it opens. Both deletion-blocking paths awaited it, which
held the hook open after the decision was made. The CMS then reported
Record Bin as slow with its "taking longer than usual" warning.

Show the notices without awaiting them and log display failures in
debug mode.

Refs #152

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both deletion-blocking messages used `ctx.notice()`, which the SDK
renders as a green success toast. Use `ctx.alert()`, the error toast,
as the rest of the plugin already does for failures.

Refs #152

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ctx.alert()` resolves only when the user closes the error toast. Code
that awaited it kept the Restore, Save and Disconnect buttons busy
until then, and delayed opening a restored record whose archive
cleanup failed. Show those alerts without awaiting them.

Settings save also reported a webhook cleanup failure as a green
success notice and awaited it for six seconds; use a non-blocking
alert instead.

Refs #152

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deleting a record now shows "Record Bin is saving a copy of this record
before it is deleted…" right away, so the few-second wait reads as work
in progress. The toast is fired, not awaited: its promise settles only
when it closes, and awaiting it would hold onBeforeItemsDestroy open.
It closes on page change (a successful delete leaves the record) or
after 15 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@roger-datocms
roger-datocms force-pushed the fix/record-bin-notice-without-wait branch from 1807aad to 7c573e1 Compare November 3, 2026 21:02
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@roger-datocms

Copy link
Copy Markdown
Member Author

Should be ready to merge along with #171

@roger-datocms
roger-datocms merged commit f560e7a into master Nov 3, 2026
@roger-datocms
roger-datocms deleted the fix/record-bin-notice-without-wait branch November 3, 2026 21:36
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.

1 participant