Skip to content

feat: export unwrapProxy and IS_PROXIED from public API#6

Merged
apankov1 merged 1 commit intodevfrom
fix/export-unwrapProxy
Dec 10, 2025
Merged

feat: export unwrapProxy and IS_PROXIED from public API#6
apankov1 merged 1 commit intodevfrom
fix/export-unwrapProxy

Conversation

@apankov1
Copy link
Copy Markdown
Owner

Summary

Exports unwrapProxy and IS_PROXIED from the main package entry point.

Problem

The unwrapProxy function was added in PR #5 (cherry-pick of cloudflare#100) but only used internally for RPC auto-unwrapping.

Consumers need direct access to unwrapProxy for:

  • structuredClone() calls on @persist objects
  • Manual serialization in non-RPC contexts
  • Caching operations

Solution

Export both symbols from index.ts:

  • unwrapProxy<T>(value: T): T - Recursively strips proxy wrappers
  • IS_PROXIED - Symbol to detect proxied objects

Usage

import { unwrapProxy } from '@cloudflare/actors';

// Before: DataCloneError
const cached = structuredClone(this.persistedField);

// After: Works correctly
const cached = structuredClone(unwrapProxy(this.persistedField));

Allows consumers to manually unwrap @persist proxies for
structuredClone and other non-RPC serialization use cases.

Related to cloudflare#100
@apankov1 apankov1 merged commit 745598f into dev Dec 10, 2025
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