[whatwg] Web Workers feedback

Jonas Sicking jonas at sicking.cc
Tue Mar 30 00:54:15 PDT 2010

On Tue, Mar 30, 2010 at 12:20 AM, Ian Hickson <ian at hixie.ch> wrote:
> On Mon, 29 Mar 2010, Jonas Sicking wrote:
>> >
>> > We could throw an exception, but that would make migrating from this
>> > not being supported to this being supported later a lot harder (you'd
>> > have to catch exceptions and then remove the nodes, rather than just
>> > doing null checks in the worker). I don't know that that's worth it.
>> I don't see why it would be harder to add support for passing objects
>> later harder. I would say quite the opposite. People are more likely to
>> come to depend on objects down in an object graph being converted to
>> null, than they are to come to depend on that throwing an exception.
> I agree that people are less likely to depend on exceptions. The problem
> is feature detection so that you can use the new feature (sending DOM
> nodes) in new clients without failing in old clients. When sending null
> it's easy; when raising exceptions, you have to have two different sends.

I would rather argue that throwing an exception makes feature
detection simpler. That way you can do something like:

try {
} catch() {
  var f = {};
  f.x = obj.x;
  f.y = obj.y;
  f.complex = serializeOrCreateOtherFallback(obj.complex);

If null is sent you have to inside the worker send back an error
message to the sender. The sender has to find the correct data to
send, which could be hard given that the error message is received
asynchronously, and then resend.

>> Additionally, it's unlikely that converting to null is the fallback
>> behavior you want for downlevel clients. Likely you'd want to manually
>> serialize such objects and then parse them on the receiver side. In this
>> case too an exception would likely help you more than silently
>> converting to null.
> It depends on how critical the DOM node is. If it's just a reference deep
> inside some nested structure, which the other side only uses as an
> additional hint rather than as a required component of the corresponding
> algorithm, it's simpler just to have the UA convert it to null.

Ok, I guess it comes down to if we think it's more likely that people
will send Nodes and other unsupported objects by accident or as
optional data, or because they really want to send them.

Personally my guess it's more likely that they really wanted to.

/ Jonas

More information about the whatwg mailing list