Search code examples
javascriptgoogle-chromeruntime-errorupgradechromium

Uncaught TypeError: someMethod is not a function


Note: that this error happens on a fully functional product (production codebase).

This happened after upgrading Chrome to Version "119.0.6045.159".

I've also tried my code on Chromium too, after upgrading it to "121.0.6151.0"

EXAMPLE:

...
// The Database class ctor definition:
RDatabase()
{
    const SCHEMA = 'CREATE TABLE IF NOT EXISTS trajPnts(...);';
    ...
    const PRESTM = 'INSERT INTO trajPnts(x1,x2,x3,...) VALUES(?,?,?,...);';
    try
    {
        this.db = openDatabase(...);
        this.createSchema = function ()
        { 
            ...
        }
        this.insertData = function (traj)    // <--- THE "insertData" METHOD !!!
        {
            ...
        }
        this.createSchema();
    }
    catch(e)
    {
        ...
    }

}
...
// Create a Database instance:
var dbr = new RDatabase();
// Register a handler to record incoming data:
Handler.RegisterTrajHandler(
    function(traj)
    {
        dbr.insertData(traj);
    }
);
...
Uncaught TypeError: insertData is not a function

Solution

  • The problem comes from the Chrome team having removed the "already" deprecated the Web SQL Database API.

    It was an API internally based on the SQLite database engine, that was introduced in April 2009 and it was abandoned in November 2010.

    The Web SQL Database API has come to an end and got removed (finally) on the Chromium 119 release (on October 31, 2023).

    Meanwhile, the World Wide Web Consortium (W3C) encourages those needing web databases to adopt Web Storage API technologies like localStorage and sessionStorage, or IndexedDB since the deprecation of this API.

    There is also a SQLite implementation over WebAssembly for all those who like do it the SQLite way.

    Originally posted into the question by the OP. Revision history