Closed agallant closed 8 years ago
PS - for context, the demo/playground for freedom-pgp-e2e used to properly pass error messages, but stopped doing so. This fixes that (why this error came up now and wasn't a problem earlier I can't say, but I believe this is still the right fix).
@willscott chatted about this with Ray and just want to check that this seems sensible to you as well before merging, since this is a somewhat deep internals change. Thanks!
Per conversation: errors are a thing we added a bit later and so don't follow the same type-coercion enforcement as arguments and returns. It seems like we've avoided this elsewhere by rejecting with strings rather than error objects. that seems plausible to continue doing in this case as well. No strong objection to putting in the type special-cased type coercion either.
Going to go with the string approach, e.g. https://github.com/soycode/freedom-portacrypt/commit/31110f222ed8241387d4bcb27ce2752d16c9af2a
And will write up a wiki page documenting that freedom.js needs strings rather than full Error objects for message passing. Thanks!
@ryscheng @willscott
Fix https://github.com/freedomjs/freedom-pgp-e2e/issues/53
postMessage
duplicates the object it is sending, but cannot do so for functions and errors. This converts errors in the message into just their string message, so postMessage behaves as expected.