-
Notifications
You must be signed in to change notification settings - Fork 57
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
Error objects lost during serialization #234
Comments
For visibility and feedback: @lemonmade @robin-drexler @kencwng |
I'd be in favor of special-casing |
Good point, I didn't notice that errors were properly handled when thrown and just not serialized when passed around. In my specific case, I could probably get around this by changing our implementation to throw instead. Though serializing error objects shouldn't hurt, right? |
Reference for me: |
PR #255 might have helped or even fix this, I need to test again to see. |
Context
When using
@remote-ui/rpc
or any package using it, built-in error objects are serialized as{}
, which is unhelpful as any relevant information about errors happening in any function on the other side (iframe, web worker, etc) is lost when it reaches the host.Hypothesis
Since built-in error object keys aren't enumerable, when an error instance gets serialized, it detects no keys and gets serialized as
{}
.When looking at the @remote-ui/rpc package's code, it seems to confirm my assumption:
Possible solutions
According to MDN's page on Error:
What if we included a new case where we could treat
instanceof Error
as if it was a primitive to be transferred as-is?Or would it make sense to switch to
Object.getOwnPropertyNames()
instead ofObject.keys
to get non-enumerable string properties as well?The text was updated successfully, but these errors were encountered: