question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IDB name is undefined

See original GitHub issue

I am using the latest version of the absurd-sql + your sql.js (0.0.53). When I do this:

main:

function init() {
  let worker = new Worker(
    new URL('./SqlNotesRepository.worker.js', import.meta.url),
    {
      name: 'sql-notes-worker',
      type: 'module',
    },
  );

  // This is only required because Safari doesn't support nested
  // workers. This installs a handler that will proxy creating web
  // workers through the main thread
  initBackend(worker);
}

init()

worker:

import initSqlJs from '@jlongster/sql.js';
import { SQLiteFS } from 'absurd-sql';
import IndexedDBBackend from 'absurd-sql/dist/indexeddb-backend';

const run = async () => {
  let SQL = await initSqlJs({
    locateFile: (file: string) => `/sqljs/${file}`,
  });
  let sqlFS = new SQLiteFS(SQL.FS, new IndexedDBBackend());
  SQL.register_for_idb(sqlFS);

  SQL.FS.mkdir('/blocked');

  SQL.FS.mount(sqlFS, {}, '/blocked');

  const db = new SQL.Database(`/blocked/123.sqlite`, {
    filename: true,
  });

  db.exec(`
    PRAGMA journal_mode=MEMORY;
  `);

  let sqlstr =
    "CREATE TABLE IF NOT EXISTS hello (a int, b char); \
INSERT INTO hello VALUES (0, 'hello'); \
INSERT INTO hello VALUES (1, 'world');";
  db.run(sqlstr); // Run the query without returning anything
};

run();

The new IndexedDB DB got created, but its name is undefined

image

But in your example site, IndexedDB DBs have the correct names 🤔

Also, on page reload I am getting this message on insert:

image

And I think it somehow may relate to the issue 🤔 The interesting is that when it overwrites(I guess) all blocks from the previous site open — it starts working well.

Btw, great lib 👍 I was making a note-taking app, and I was on stage where I was needed to introduce a full-text search, and in IndexedDB it is a headache. Now I am going to rewrite the persistence layer to absurd-sql, and I am super excited to get overall speed improvements with a text search for free 🙂 And it also gives me the easy way to improve the speed when I will be porting the app to the phones/desktops — ionic/cordova/electron has wrappers for the native SQLite.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
quolprcommented, Aug 20, 2021

But it seems that a bug in the fallback mode is still present though

0reactions
quolprcommented, Sep 1, 2021

Nevermind, I found that this commit https://github.com/jlongster/absurd-sql/commit/33f9898d8b1d297242fb4a7f780ac3a2062d4a58 breaks safari support

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unspecified, undefined and implementation defined behavior ...
Implementation-defined Behavior (IDB) ... This is a behavior that can be described in a way similar to UsB: the standard provides some ...
Read more >
IDBFactory.deleteDatabase() - Web APIs | MDN
The method returns an IDBOpenDBRequest object immediately, and performs the deletion operation asynchronously. If the database is successfully ...
Read more >
idb - npm
This method opens a database, and returns a promise for an enhanced IDBDatabase . const db = await openDB(name, version, { upgrade(db, ...
Read more >
The IDB Group Corporate Sustainability Index for Latin ...
It was created by the Inter-American Development Bank and its private sector arm, IDB Invest, in partnership with S-Network Global Indexes. It is...
Read more >
IndexedDB/idbobjectstore-rename-store.html - external/w3c ...
href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-name"> ... const transaction = database.transaction('undefined', 'readonly', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found