Skip to content

feat(runtime-sdk): improve DO-related type conversions#113

Open
ryanking13 wants to merge 4 commits into
gyeongjae/storage-bindingsfrom
gyeongjae/do-bindings-test
Open

feat(runtime-sdk): improve DO-related type conversions#113
ryanking13 wants to merge 4 commits into
gyeongjae/storage-bindingsfrom
gyeongjae/do-bindings-test

Conversation

@ryanking13
Copy link
Copy Markdown
Contributor

This PR is on top of #112 (the target branch).


In addition to #112, this PR adds a few more type conversion improvements in our SDK to make Durable Object bindings work more seamlessly.

It includes

  1. Wrap Python functions with create_proxy when passed to the RPC boundary, so that the function is not garbage collected after the function returns. The FinalizationRegistry will now be responsible to cleaning up the function reference later.

  2. Wrap do.ctx.storage with RPC wrapper so that type conversions are applied there as well just like other bindings.

  3. Added more test cases that covers DO api surfaces.

@ryanking13 ryanking13 requested review from dom96, hoodmane and joesepi May 28, 2026 05:45
Copy link
Copy Markdown

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR adds create_proxy wrapping for callables at the RPC boundary, wraps DurableObjectStorage with _RPCWrapper for consistent type conversions, and adds comprehensive DO binding tests.

Issues

  1. Dead code: LambdaType check is now unreachable — The new early return for callables at line 1003 of _raise_on_disabled_type means the LambdaType branch on line 1009 can never be reached (lambdas are callable and not type). The LambdaType check — and its import on line 20 — should be cleaned up to avoid confusion. Note that tuple and bytearray in that same isinstance check are still reachable since instances of those types are not callable, so those still need guarding.

Suggested change at packages/runtime-sdk/src/workers/_workers.py line 1009:

# Before:
    if isinstance(value, (tuple, bytearray, LambdaType)):
# After:
    if isinstance(value, (tuple, bytearray)):

And remove the now-unused import from types import LambdaType on line 20.

return

if callable(value) and not isinstance(value, type):
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new early return for callables makes the LambdaType check on line 1009 dead code — lambdas are callable and not type, so they'll always return here before reaching isinstance(value, (tuple, bytearray, LambdaType)).

Consider removing LambdaType from the tuple on line 1009 (changing it to isinstance(value, (tuple, bytearray))) and dropping the from types import LambdaType import on line 20.

@ask-bonk
Copy link
Copy Markdown

ask-bonk Bot commented May 28, 2026

Review posted successfully on PR #113. I found one actionable issue:

Dead code from LambdaType: The new early return for callables in _raise_on_disabled_type (line 1003) makes the LambdaType branch on line 1009 unreachable, since lambdas are callable and not type. I posted an inline comment on the diff line with a suggested fix (remove LambdaType from the isinstance check and its import).

The rest of the PR looks solid -- the DurableObjectStorage wrapping with _RPCWrapper, the create_proxy wrapping for callables at the RPC boundary, and the comprehensive test coverage for DO APIs are all well-structured.

github run

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