Closed Bug 377347 Opened 17 years ago Closed 13 years ago

Javascript exceptions that occur within an async callback do not cause window.onerror events or appear in the debug console

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
major

Tracking

()

RESOLVED DUPLICATE of bug 503244

People

(Reporter: bugzilla, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.1; .NET CLR 2.0.50727)
Build Identifier: 2.0.0.3

Normally exceptions such as those from:

throw "error"

Cause a window.onerror event or appear in the debug console. But when an error occurs within a function that is a callback to an asynchronous request, neither happens.

Reproducible: Always

Steps to Reproduce:
1. create an XMLHttpRequest
2. begin the request
3. throw an error or create a runtime error in the handler.
Actual Results:  
No error appears in the console and no window.onerror event is raised.

Expected Results:  
Errors from async handlers should appear in the console if they are unhandled, and should raise window.onerror events.

This is important for AJAX scenarios, as script errors that occur in response to ajax calls will not be known to the developer, and cannot be captured.
Attached file Reproduces the problem
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a4pre) Gecko/20070412 Minefield/3.0a4pre ID:2007041207 [cairo]

Upon loading the page, i get:
Warning: reference to undefined property window.console
Source file: https://bugzilla.mozilla.org/attachment.cgi?id=261429
Line: 7

Warning: reference to undefined property window.console
Source file: https://bugzilla.mozilla.org/attachment.cgi?id=261429
Line: 7

Error: window.console has no properties
Source file: https://bugzilla.mozilla.org/attachment.cgi?id=261429
Line: 7

And after clicking the button I get
Error: createError is not defined
Source file: https://bugzilla.mozilla.org/attachment.cgi?id=261429
Line: 1
It assumes window.console is available. I guess thats an optional component? Is the javascript console installed? I have firebug but it still repros when I disable it.
Also the 'create error' button in the repro is meant to cause an error, just to show what an error is supposed to look like. The repro is that when the page starts up, an xmlhttprequest is made where there's an error within the readystatechange callback, yet no error appears and window.onerror doesn't fire. Again you need the debug console installed.
I have *sort of* the same problem. When I make an Ajax callback, and then deliberately produce an error in the callback, this gets properly logged in the Firebug console. However, when I do the same with a Prototype encoded Ajax call this does not get logged.

I think it is somehow related to this bug - anyway the attachment here definitely shows something is not correct, the throw statement is indeed not logged.

The following pages that I put online may provide more information (you must have Firebug installed):

http://www.elvanor.net/test/drag/normal_ajax.html // this is the page that shows that a runtime error is caught when using a normal Ajax call.

http://www.elvanor.net/test/drag/prototype_ajax.html // here this is not logged, although the only change is to use a Prototype callback.

For me this bug is really, really annoying. Any chance to see it fixed soon? The same exact behavior happens in the Opera error console too, btw.
Oh, and I forgot to add that this happens in Linux too - this is my platform.
Changing component to Core->Javascript Engine for greater visibility
Component: Error Console → JavaScript Engine
Product: Firefox → Core
You only get the "greater visibility" of Brendan throwing it back out of JS engine if you remember to reassign.
Assignee: nobody → general
QA Contact: error.console → general
I have updated the URLS:

http://test.elvanor.net/bugs/firefox-ajax-logging/normal_ajax.html

and

http://test.elvanor.net/bugs/firefox-ajax-logging/prototype_ajax.html

The olds one result in 404.

Please, can someone confirm this bug?? It's still present in latest Firefox...
This is certainly not JS engine.

The browser JS "universe" has lots of APIs and extensions to the core ECMA-262 language. Most of the extensions are part of the DOM standards, with many others part of the browser object de-facto standards. Bugs to do with XHR and onerror do not go in Core / JavaScript Engine.

It may be hard to pinpoint the right component. I'm gonna guess DOM: Core & HTML.

/be
Assignee: general → nobody
Component: JavaScript Engine → DOM: Core & HTML
QA Contact: general → general
I can reproduce bug in firefox 4, but it seems to have gone in firefox 5. Can someone confirm this ?
Given that a patch for bug 503244 fixes this (and no, arno, I can reproduce this bug in trunk), I'm marking this a dup.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: