Proxies in a ShadowRealm: can someone post an example?

2 views
Skip to first unread message

Alex Vincent

unread,
Apr 13, 2022, 1:49:37 PM4/13/22
to SES Strategy
Hi, all.  I've been trying off and on to figure something out about proxies created in a shadow realm.

Specifically, I've been operating under the assumption that a membrane needs to create a Proxy inside a ShadowRealm to an object outside the realm.  The more I look over the ShadowRealm proposal, though, the less I see how that's possible.

You need a ProxyHandler and a (shadow) target in the realm.  That handler has to communicate synchronously with something outside the realm in order to support the proxy's traps.  The proxy trap needs to get the answer from the outside before it can exit.

Compartments have the same problem.

Alternatively, I could see trusted code passing a proxy into a realm, but the API's for realms seem to disallow that (probably for good reason).

Now I strongly believe that someone out there working on membranes in the ShadowRealm shims has solved this.  I keep banging my head on the wall every time I try to conceptually figure this out.  Membranes depend on proxies that can communicate synchronously across boundaries.  Could someone please send me example code that illustrates how this can happen?

Alex Vincent
Hayward, CA

--
"The first step in confirming there is a bug in someone else's work is confirming there are no bugs in your own."
-- Alexander J. Vincent, June 30, 2001

Mathieu Hofman

unread,
Apr 13, 2022, 1:58:27 PM4/13/22
to Alex Vincent, SES Strategy
You may want to look at @caridy's irealm approach which is now part of Salesforce's near-membrane. TLDR, you pass a function which can synchronously set a "global" to the "selected" object, which is then immediately consumed and reset, so that your proxied calls basically do: call this method with these args on a target which can be selected through this function.

I'll let caridy explain it better. The code is pretty dense, but straightforward once you've got the basic idea.

I'm curious to hear what alternative approach was imagined by Axel (did I get the name right?)

Mathieu

--
You received this message because you are subscribed to the Google Groups "SES-strategy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ses-strategy...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ses-strategy/CAEZ8440e7Rv3Z95K00WQxFqo1F0LBUHU4vKBfDCdpq8Q3yUc4A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages