Skip to content

[sharedb] Add 'retry' middleware action - #75750

Draft
dawidreedsy wants to merge 1 commit into
DefinitelyTyped:masterfrom
dawidreedsy:sharedb-retry-middleware
Draft

dawidreedsy wants to merge 1 commit into
DefinitelyTyped:masterfrom
dawidreedsy:sharedb-retry-middleware

Conversation

@dawidreedsy

Copy link
Copy Markdown
Contributor

Summary

Adds the new 'retry' middleware action from share/sharedb#761 to middleware.ActionContextMap.

retry is triggered when an op loses the race to commit, before it is retried against a newer snapshot. Middleware can use it to reset state stored on the request during the failed attempt. It receives the same SubmitRequest as the other submit actions, so it is typed as SubmitContext (with no $fixup, which is only valid in 'apply').

backend.use("retry", (context, next) => {
    delete context.snapshotBeforeApply;
    next();
});

sharedb-tests.ts adds "retry" to the submit-related actions loop, plus a check that $fixup isn't allowed in it.

Draft until share/sharedb#761 is merged and released. The version in package.json will need bumping to match that release if it ships as a minor.


If changing an existing definition:

  • Provide a URL to documentation or source code which provides context for the suggested changes: ✨ Add retry middleware action share/sharedb#761
  • If this PR brings the type definitions up to date with a new version of the JS library, update the version number in the package.json. (pending the sharedb release)

cc @alecgibson @ericyhwang

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Author Action

Development

Successfully merging this pull request may close these issues.

1 participant