Skip to content

docs: add callback retention example to Duplicating stubs#172

Open
SAY-5 wants to merge 1 commit into
cloudflare:mainfrom
SAY-5:docs/callback-examples
Open

docs: add callback retention example to Duplicating stubs#172
SAY-5 wants to merge 1 commit into
cloudflare:mainfrom
SAY-5:docs/callback-examples

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 21, 2026

Refs #30.

In #30, @kentonv (member) said "I agree we could use more examples of callbacks." The follow-up comment showed the typical pitfall: a setCallback(cbfunc) method that stores cbfunc and invokes it later from a timer throws "Attempted to use RPC stub after it has been disposed" unless the stub is duplicated with .dup().

This adds a short subsection to "Duplicating stubs" in the README with:

  • the bidirectional-callback pattern that motivates .dup(),
  • a 12-line RpcTarget example that stores cbfunc.dup() and disposes it from [Symbol.dispose],
  • a note that the same rule applies in the reverse direction (client retaining a stub returned by the server).

README only. No code changes.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

⚠️ No Changeset found

Latest commit: 21b1ebb

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@SAY-5
Copy link
Copy Markdown
Author

SAY-5 commented May 21, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 21, 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.

1 participant