skip to Main Content

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

2

Answers


  1. As pointed out by Yogi in the comments, this is likely to do with the fact that the Web SQL standard has been deprecated for a long while and is finally removed in Chromium 119.

    The issue is obscured by the try/catch in your original code; since openDatabase fails (presumably "openDatabase is not defined" or similar), the this.createSchema and this.insertData functions never get defined either:

    function RDatabase() {
      try {
        this.db = openDatabase();
        this.insertData = function(traj) {};
      } catch (e) {
        console.error(e);
      }
    }
    
    
    var rdb = new RDatabase();
    console.log(rdb.db);
    console.log(rdb.insertData);

    If you still need the SQLite API going forward, you will need to migrate to e.g. this SQLite WebAssembly port (linked in the aforementioned blog post as a recommendation by the Chrome team).

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search