Question

I'm trying to write a Sencha Touch 2.0 WebSql proxy that supports tree-data. I started from tomalex0's WebSql/Sqlite proxy. https://github.com/tomalex0

When modifying the script I ran into a strange debugging issue:

(I'm using Chrome 17.0.963.78 m)

The following snipped just got jumped over. The transaction never takes place! But when I set a breakpoint above or below and I run the same code in the console, it does work!

dbConn.transaction(function(tx){
    console.log(tx);
    if (typeof callback == 'function') {
        callback.call(scope || me, results, me);
    }
    tx.executeSql(sql, params, successcallback, errorcallback);
});

The blue log you can see, the green log is from the success handler. When the query would be performed there would be exactly the same log above (it's a SELECT * FROM ...; so when performing multiple times without changing data I would expect the same result)

I found out that when I add the code block to the watch expressions it also runs.

Debug Example

Was it helpful?

Solution

It isn't being skipped over. It is being scheduled, but not being executed till much later due to the asynchronous nature of the request:

http://ejohn.org/blog/how-javascript-timers-work/

Since the code is being executed synchronously to make the asynchronous call it will delay the call till after the synchronous code has been executed, due to the single threadedness of javascript.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top