TinyJoin logoTinyJoin

close

The close method detaches this Client and releases its prepared statements and Worker. Other Clients for the same OPFS name stay connected; ownership transfers automatically when necessary. Repeated calls share the same asynchronous cleanup. A closed Client cannot resume; create a new one and recreate its prepared statements and subscriptions. Closing is not a cancellation or rollback guarantee for a write already in flight.

close(): Promise<void>

Example

import {create} from 'tinyjoin';

const db = await create('opfs://my-app-v1');
try {
  await db.exec(`
    CREATE TABLE IF NOT EXISTS tasks (id TEXT PRIMARY KEY)
  `);
} finally {
  // Releases the Worker and its hold on the storage, whatever happened.
  await db.close();
}
console.log(db.closed);
// -> true