ujjwalguptaofficial / JsStore

Simplifying IndexedDB with SQL like syntax and promises
http://jsstore.net/
MIT License
858 stars 110 forks source link

Maximum call stack size exceeded #9

Closed michel-reyes closed 7 years ago

michel-reyes commented 7 years ago

Hi, I try to create a insert statement from a huge (40000 records) and then I get the Maximum call stack size exceeded. How can I solve this?

ujjwalguptaofficial commented 7 years ago

Hi there - there was an issue with insert query, now it is solved. You can grab the latest version (1.2.5) and use. Let me know if you are getting this issue any more.

Thanks

michel-reyes commented 7 years ago

Sorry, the problem persist

RangeError: Maximum call stack size exceeded at h (JsStore-1.2.5.min.js:4)

Here is part of my code

conn.insert({
            Into: 'locations',
            Values: locations, // this is a array of objects a 6 Mib file
            OnSuccess: function(rowsAffected) {
                if (rowsAffected > 0) {
                    console.log('Succesfully added ' + rowsAffected + ' row(s)');                                   
                }               
            },
            OnError: function(err) {
                console.log(err.value);
            }
        }); 
ujjwalguptaofficial commented 7 years ago

The new version is 1.2.5 . Are you using this version ?

michel-reyes commented 7 years ago

Yes I'm using the lastest version, I edit the post. It is the 1.2.5 version and is the same problem.

ujjwalguptaofficial commented 7 years ago

Can use 'SkipDataCheck' to see the problem persist

conn.insert({
    Into: 'locations',
    Values: locations, // this is a array of objects a 6 Mib file
    SkipDataCheck:true, // will not do any validation just insert data
    OnSuccess: function(rowsAffected) {
        if (rowsAffected > 0) {
            console.log('Succesfully added ' + rowsAffected + ' row(s)');                                   
        }               
    },
    OnError: function(err) {
        console.log(err.value);
    }
});

If you want to make the insertion more faster use bulkinsert - http://jsstore.net/tutorial/bulk_insert

michel-reyes commented 7 years ago

Not yet. If I use SkipDataCheck it says: "Table 'locations' does not exist" otherwise: Maximum call stack size exceeded

michel-reyes commented 7 years ago

Not yet. If I use SkipDataCheck it says: "Table 'locations' does not exist"

otherwise: Maximum call stack size exceeded

`

// helper funtions // milliseconds to seconds to log the function's performance function performanceLog(fun, m) { return console.log("Load " + fun + " took " + m.toFixed(2) + " milliseconds / " + (m/1000).toFixed(2) + " seconds."); }

// Enable db library logs //JsStore.enableLog();

// global vars var table, dbName = 'gls', db, conn, t1, t0;

//--------------------------------

conn = new JsStore.Instance(); JsStore.isDbExist(dbName,function(isExist){ if(isExist) { console.log('Db already created'); conn.openDb(dbName);

    console.log('populate table');
    populateTable();        
}
else
{
    console.log('Db does not exist, creating..');
    table = {
        Name: 'locations',
        Columns: [
            {
                Name: 'State',
                DataType: 'string'      
            },
            {
                Name: 'City',
                DataType: 'string'
            },
            {
                Name: 'CountryCode',
                DataType: 'string'
            },
            {
                Name: 'PayerCode',
                DataType: 'string'
            },
            {
                Name: 'BranchCode',
                DataType: 'string'
            },
            {
                Name: 'Street',
                DataType: 'string'
            }
        ]
    };

    db = {
        Name: dbName,
        Tables: [table]
    };

    conn.createDb(db, function(){
        console.log('Db created successfully'); 
        console.log('populating table');
        populateTable();
        console.log('populated table');                     
    });
}

});

//------------------

function populateTable() {

conn.insert({
    Into: 'locations',
    Values: locations, // this is a array of objects a 6 Mib file
    SkipDataCheck:true, // will not do any validation just insert data
    OnSuccess: function(rowsAffected) {
        if (rowsAffected > 0) {
            console.log('Succesfully added ' + rowsAffected + ' row(s)');                                   
        }               
    },
    OnError: function(err) {
        console.log(err.value);
    }
}); 

}

`

ujjwalguptaofficial commented 7 years ago

May I know - In which browser you are working ?

michel-reyes commented 7 years ago

Chrome Version 61.0.3163.100 (Official Build) (64-bit)

ujjwalguptaofficial commented 7 years ago

ok thanks. please use the same code in incognito with skipdatacheck on . Let me know what is the result.

It may be that db has became buggy due to exception thrown.

ujjwalguptaofficial commented 7 years ago

Can you please upload your code on jsfiddle or something like this or you can give me files. It will be more helpful.

michel-reyes commented 7 years ago

Perfect! But not for the incognito mode, I update my chrome browser to version 62, and everything works great. I'm afraid if the old browsers can't work as well

michel-reyes commented 7 years ago

Trying in IE....

ujjwalguptaofficial commented 7 years ago

great ! it should work in older version too even in incognito. Is chrome incognito not working for you ?

michel-reyes commented 7 years ago

Ok, I'm going to clean my browser, restart my PC to try to replicate the error again

ujjwalguptaofficial commented 7 years ago

yeah cleaning the storage should work. Make sure you are not seeing any db in indexeddb tab.

ujjwalguptaofficial commented 7 years ago

@neomicho85 - is it working fine for other browsers? or is there any problem ?

Can we close this issue if everything good?

michel-reyes commented 7 years ago

I try in ie10, chrome 61 and 62 everything's ok. Thx