The default bug view has changed. See this FAQ.

Web worker onerror event object has blank message property

RESOLVED DUPLICATE of bug 557346

Status

()

Core
DOM
RESOLVED DUPLICATE of bug 557346
8 years ago
7 years ago

People

(Reporter: Nicholas C. Zakas, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.13) Gecko/2009073022 Firefox/3.0.13

When an error occurs in a web worker script, the onerror event handler in the main page is called and the event object correctly contains a message property, a lineno property, and a filename property. The only problem is that the message property isn't filled in (it's always an empty string).

//in page
var worker = new Worker("worker.js");
worker.onerror = fucntion(event){
    alert("[" + event.message + "]");  //always empty string
};
worker.postMessage("start");

//in worker.js
self.onmessage = function(event){
    throw new Error("Something bad happened.");
};


Reproducible: Always

Steps to Reproduce:
1. Run above code
Actual Results:  
The alert displays "[]".

Expected Results:  
The alert displays "[Something bad happened.]"
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general

Comment 1

7 years ago
It seems it depends what is thrown:

//in worker.js (FF 3.6.3 on Win7)

1) throw new Error("Something bad happened."); –> handler's event.message is ""
2) throw "something" –>  "something"
3) throw something_undefined –>  "something_undefined is not defined"
4) throw new MyObjectWith_toString("something") –>  "uncaught exception: something"
5) throw new MyObjectWithout_toString("something") –>  "uncaught exception: [object Object]"

where MyObjectWith_toString is a custom object with a toString() method.

Chrome (5.0) prepends the message with "Uncaught : ", so

1) "Uncaught Error: Something bad happened."
2) "Uncaught something"
3) "Uncaught ReferenceError: something_undefined is not defined"
4) "Uncaught something"
5) "Uncaught #"

Comment 2

7 years ago
hmmm... changes in FF 3.6.4 (win 7)

1) throw new Error('Something bad happened.'); –> "Something bad happened."  (FIXED!)
2) throw 'something' –>  'uncaught exception: something'  (SAME))
3) throw something_undefined –> == 'something_undefined is not defined' (SAME)
4) throw new MyObjectWith_toString('something') –> == 'uncaught exception: [object Object]' (REGRESS!)
5) throw new MyObjectWithout_toString('something') –> == 'uncaught exception: [object Object]' (SAME)

Comment 3

7 years ago
in Comment 1: #5 for chrome should read:

5) "Uncaught #<a MyObjectWithout_toString>"
Status: UNCONFIRMED → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 557346
You need to log in before you can comment on or make changes to this bug.