Closed Bug 700421 Opened 8 years ago Closed Last year

Syntax errors in xpcom components aren't reported


(Core :: XPConnect, defect)

Not set





(Reporter: florian, Unassigned)



(1 file, 1 obsolete file)

A syntax error in the JS file of an xpcom component causes it to fail to load, but there's no error message related to the actual error (neither in the error console, nor in the terminal on debug builds).

The only visible error (Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]) doesn't help at all. This bug is causing significant (and recurrent) wastes of time for several developers (I had the confirmation on IRC while asking for a workaround that at least 2 other people had already painfully become aware of this bug in past experiences).

 - Reference errors from code executed during the initialization of the service were correctly reported during my testing. The bug seems only on syntax errors.
 - I observed this on a Mac debug build based on Mozilla 7.
 - For the readers looking for a workaround rather than willing to fix the bug, here is how I finally found my syntax error (after wasting over an hour and a half looking for the error / a way to locate it) : ./xpcshell component/<component-name>.js
 That gave me a very clear "SyntaxError: missing ) after argument list" error message with location information.
Would be great to have exacts steps to reproduce (with some example component).
jdm's been doing work on this kind of stuff over in bug 463122. Maybe he might be interested in taking a crack at this one too? :-)
Attached patch testcase (obsolete) — Splinter Review
This is enough to reproduce on a current mozilla-central debug builds.
In the error console, at startup I see:

Error: [Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]"  nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)"  location: "JS frame :: file:/// ... / :: clh_handle :: line 44"  data: no]
Source File: file:/// ... /
Line: 44

If I paste this in the error console:
The result is:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE) [nsIJSCID.getService]"  nsresult: "0x80570016 (NS_ERROR_XPC_GS_RETURNED_FAILURE)"  location: "JS frame :: javascript:%20Components.classes[";1"].getService(); :: <TOP_LEVEL> :: line 1"  data: no]

However, if I execute:
./xpcshell components/broken.js

The result I see is:
components/broken.js:4: SyntaxError: missing ; before statement:
components/broken.js:4:   dump("test"));

components/broken.js:4: ..............^
Comment on attachment 582116 [details] [diff] [review]

You're missing broken.js from the patch, right?
Attached patch testcaseSplinter Review
(In reply to Josh Matthews [:jdm] from comment #5)
> Comment on attachment 582116 [details] [diff] [review]
> testcase
> You're missing broken.js from the patch, right?

yes, forgot to hg add, sorry about that :(.

The content of that file isn't very important, I first tested with a file containing only one ) character and it gave the same result. I later changed the content to something more likely to be a valid component with a syntax error, so that the xpcshell error looked like a real error.
Attachment #582116 - Attachment is obsolete: true
Per policy at If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Closed: Last year
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.