Open safareli opened 2 years ago
Given the workaround is sufficient here, and adding the serialization would for most folks be unnecessary additional payload do you think this is actually worth adding to the library, or should we just document the workaround for those folk that need it?
The workaround depends on internal api and needs unsafe type casts. it would be nice to just use serialize-error but if adding dependency is a problem then making API of swapping out transferHandlers in a nicer way would be one option.
Maybe some sort of plugin api could be implemented here. and there would be a plugin that uses serialize-error for errors
I guess I missed the usage of an internal api, which part uses that?
If you want to put up a PR to use serialize-error
so we can compare payload impact that'd be the best path forward here. Besides that I think we would need more indication of this being a consistent problem for users to determine if its worth addng the additional payload for this.
If you are using custom error classes with custom properties or even more or less standard
cause
then you would loose some data here: https://github.com/GoogleChromeLabs/comlink/blob/4ba8162f6c28fb1bf53b491565ef9a3ae42b72d3/src/comlink.ts#L249-L256Instead I'm proposing to use
serialize-error
that works better then what we have currently.I can create PR if this is approved.
Meanwhile you can do this as a workaround