adobe-research / theseus

A pretty darn cool JavaScript debugger for Brackets
Other
1.34k stars 69 forks source link

Theseus and Jquery Throwing Errors on Live Preview #46

Open pixelshaded opened 10 years ago

pixelshaded commented 10 years ago

Sprint 34 experimental build 0.34.1-10733 Using bower installed jquery version 2.0.3.

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="scripts/bower_components/jquery/jquery.js"></script>
</head>
<body>

</body>
</html>

SyntaxError: Failed to execute query: '*,:x' is not a valid selector. (line 1482) SyntaxError: Failed to execute query: '[s!='']:x' is not a valid selector. (line 1514)

It is happening in the assert functions in jquery that checks for browser support.

alltom commented 10 years ago

Do you know if the jQuery is minified?

alltom commented 10 years ago

When I try it with jQuery off the jQuery site, I get no exceptions just from loading jQuery, but I get 2 exceptions with minified jQuery:

[Error] TypeError: 'undefined' is not a function (near '...4-6267", vars: {} })(t))...') (j2.js, line 1650)
[Error] TypeError: 'undefined' is not a function (near '...4-2917", vars: {} })(o,[x]),x.fn.trigger...') (j2.js, line 1596)

Let's see where these are coming from...

pixelshaded commented 10 years ago

It is not the minified version. Note that everything seems to run fine with theseus turned off. These errors arent getting thrown.

pixelshaded commented 10 years ago

I downloaded the latest unmin'd version of jquery from their site at http://code.jquery.com/jquery-2.0.3.js and I'm still getting those errors.

alltom commented 10 years ago

That's weird. I'll see how closely I can recreate your setup.

pixelshaded commented 10 years ago

Note that the extension downloaded by brackets is v.0.4.8 - 2013-09-03

cthrax commented 10 years ago

Was there any insight into this? I am also seeing this, though not with theseus, but other jquery plugins.

alltom commented 10 years ago

No, not yet, sorry. I think there was another report about jQuery 2 being broken but I haven't found the time to look into either yet.

It can be worked around by requesting jquery.js?theseus=no for the time being.

cthrax commented 10 years ago

No worries, thanks for the quick response!

QuentinRoy commented 9 years ago

Same problem here with the very last theseus version (0.4.13), very last bracket version (41) and very last unminified jquery version (2.1.1).. Do you have new insights about this issue and where it comes from? I cannot use the theseus=no trick as I'm using requirejs... :-/

alltom commented 9 years ago

Sorry. :\

If the problem is what I think it is, when fondue inserts the instrumentation code for Theseus, it unintentionally makes the JavaScript invalid. Before the initial release of Theseus, I spent several days just getting minified jQuery to work because it uses every trick it can to make the file as small as possible. It seems like they found a new trick for jQuery 2 that I haven't figured out.

If I'm correct, unminified jQuery ought to work, and inserting /*theseus instrument: false */ into jQuery somewhere ought to work.

I'm bumping this to the top of my todo list to look at today. :)

alltom commented 9 years ago

You all are getting the errors in Chrome, right?

alltom commented 9 years ago

All right, I can finally reproduce this!

alltom commented 9 years ago

It turns out that the exceptions are benign, if annoying. :)

jQuery's assert() returns false if the assertion throws an exception. However, Theseus logs all exceptions that cause a function to abort, even if they're caught somewhere else (such as in assert()). So even though the exceptions are part of the normal browser detection control flow, they show up in Theseus's events bar.

There are a couple of things that should be done:

If you don't care what happens in jQuery, I recommend disabling Theseus for that file using one of the methods mentioned earlier (which also described here).

alltom commented 9 years ago

If an exception is caught, the stack will show where:

screen shot 2014-08-02 at 3 18 14 pm

If an exception is not caught, you can now see it propagate all the way up the stack:

screen shot 2014-08-02 at 3 18 58 pm

The log now only shows uncaught exceptions. However, the exception counter is now wrong because it's counting the number of invocations that exited with an exception instead of the number of times an exception made it all the way up the stack:

screen shot 2014-08-02 at 3 19 13 pm

alltom commented 9 years ago

With that commit to Theseus, I think this issue is resolved. Could someone (preferably everyone :) try this test build of Theseus?