-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-realm serialization/deserialization issues #31
Comments
Identity discontinuity is a real pain. I don't think providing expansion slots of any kind will help here because we also serialize functions, and if those functions are parsed and evaluated in a different realm, the objects that they produce (imagine that the function returns a regexp) will always exhibit different identity. The solution must be in user-land by evaluating the code in the correct sandbox, or work around the identity discontinuity problems. |
This sounds like the third option I mentioned here, right? I.e., the user should just make sure to eval the serialized result in a realm with globals that come from the same realm that serialize-js is running in. If so, that seems suboptimal to me. Of course, I agree that this library can't control the identity of the objects produced during deserialization. Still, during serialization, it does seem like the library could correctly identify objects as RegExps or Dates, even if those objects come from a different realm. I think that would be a good thing to do, probably using the second option I mentioned in #27:
|
Yeah, I'm fine with that. My only concern is the performance of the serialization. @ljharb's packages seem to be optimized (I can probably raise this question next week when I see him in person) but I haven't try them. Remember that we will have to do that for every non-function object node in the object graph. |
Makes perfect sense. I'll let you raise it with him and decide what's best. |
All of my "is-*" libraries are "optimized" in the sense that they have as many fast paths as possible - they return false as early as they can, and in environments that are pre- If you want to do fast brand checking, the proper path is likely to be https://github.com/jasnell/proposal-istypes (which my packages could help to polyfill). |
I just wanted to open a dedicated issue for the conversation here, so that it doesn't get lost.
The text was updated successfully, but these errors were encountered: