All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
One change in this release can make a call that succeeds on 1.4.3 report an error: js_create_*()
now fails when it cannot store the function in the js_functions table. See Changed. The rest
are fixes for errors that were silently dropped, one of them a crash.
js_create_scalar,js_create_aggregate,js_create_windowandjs_create_collationreport an error when the function cannot be stored injs_functions. 1.4.3 reported success, and the function was then gone when the database was reopened. The message reads "The function was registered on this connection, but it could not be stored in js_functions", followed by SQLite's reason, and the error code is SQLite's own: for example SQLITE_READONLY on a read-only connection or underPRAGMA query_only, or SQLITE_BUSY when another connection is writing. The function is still registered and works on this connection. Nothing changes for a database without ajs_functionstable.
- An argument that cannot be converted no longer makes a function run with fewer arguments. When putting an argument into the array a JavaScript function receives failed, because QuickJS ran out of memory or because a script had put a setter on
Array.prototype, the function ran without that argument and the exception stayed pending. The call now fails with that exception before the function runs. toArray()no longer returns shorter rows or a shorter array when a value cannot be stored. It now throws that exception. As when allocating a row fails, the result set stays open after the row that failed, so a script that catches the exception and reads on gets the rows after it.- Text that SQLite cannot convert to UTF-8 no longer crashes. When SQLite ran out of memory converting text, for example on a UTF-16 database, the NULL it returned was passed to
strlen(). It is now an "out of memory" error.
This release adds one C function, sqlitejs_cancel_all(), for a host that has no other way to stop
JavaScript that does not come back. Nothing changes for an application that never calls it: SQL and
JavaScript behave exactly as on 1.4.2 until a cancel arrives.
sqlitejs_cancel_all()stops all JavaScript running now, in every connection. Each call into JavaScript fails with an "interrupted" error, even code that catches every exception, and JavaScript that begins afterwards runs normally. It is safe to call from any thread, and it works on every SQLite version, including those before 3.41.0 wheresqlite3_interrupt()cannot reach JavaScript at all. It exists for hosts whose own cancelling cannot: Android cancels a query with a progress handler, which SQLite never calls while a function is running, and Room 2.7 and later pass no cancellation signal at all, so a runaway function could previously only be stopped by killing the process. The connection whose JavaScript is stopped is interrupted as well, assqlite3_interrupt()does it, because a collation cannot report an error and its sort would otherwise go on calling JavaScript, each call beginning after the cancel; so any other statement that connection has in progress fails with SQLITE_INTERRUPT too, andsqlite3_is_interrupted()stays true for it until the connection next prepares or steps a statement with none of its own still running. The function is declared insqlitejs.hand exported from the Windows DLL.- A result set the cancelled call left open reads on as "interrupted", where 1.4.2 says it was closed when the call that created it returned. Ending such a result set runs the
finalof the window or aggregate function its statement was computing, and those finals belong to the call that is being cancelled: one that never ends is stopped, and its statement fails with an interrupt, rather than hanging the statement for good on SQLite before 3.41.0. A shortfinalcan still run to its end before the engine's next interrupt check. - A cancel never stops the JavaScript the extension itself runs to set a connection up, so a connection opening while cancels are in flight still comes up complete: neither the code run while the extension loads nor the functions
js_init_table(1)restores from thejs_functionstable are cancelled. Only that work is exempt — JavaScript it reaches through SQL is a call of its own and is cancelled — and on SQLite 3.41.0 and latersqlite3_interrupt()still stops setup JavaScript that never ends.
One change in this release can alter the behavior of JavaScript that works on 1.4.1: a db.exec()
result set no longer outlives the call into JavaScript that created it, so reading one in a later
call throws where it reported the end of its rows. See Changed. The rest is fixes, two of them
for crashes: a result set dropped partway through a query that computes a JavaScript window
function, and runaway recursion on a stack the check had measured wrongly.
- A
db.exec()result set no longer outlives the call into JavaScript that created it. Reading one afterwards —next(),toArray(),get()orname()— now throws "The result set was closed when the call into JavaScript that created it returned", wherenext()reported the end of its rows andtoArray()returned an empty array. Keeping a result set across calls never worked as it looked: its statement stayed open, which held a read transaction open, kept an interrupt in effect until the connection closed, and leaked the connection — see both result set entries under Fixed. A result set read to its end still reports the end of its rows, and an interrupted one still says "interrupted".
- Deep recursion could still crash the process instead of failing with "Maximum call stack size exceeded", in four more cases. The 1.4.0 entry below describes the measurement each call into JavaScript makes of the stack it runs on; these are the cases it got wrong. A thread with less than
SQLITE_JS_STACK_MINof stack left kept the connection's size, 1 MB by default, which that stack cannot hold, soSELECT forever()on a 64 KB thread crashed; any measurement is now kept. For the initial thread the bound was counted from the stack pointer, so a first measurement deep in the stack put it below the real one: with the extension first used 1 MB deep in an 8 MB stack,js_set_max_stack_size()offered 7.75 MB and runaway recursion crashed. It is now counted from the top of the stack, as the kernel counts it — from the kernel's own mapping, which is above the block of argv and environment thatpthread_attr_getstack()does not reach, so that 360 KB of environment no longer puts the bound 360 KB too low. And whereRLIMIT_STACKis unlimited there is no bound to measure: glibc reports nearly the whole address space,js_set_max_stack_size()offered about 85 TB, and runaway recursion took the memory of the machine until the kernel killed the process. Such a stack now counts as unmeasurable, which allows up to the 1 MB default;js_set_max_stack_size(0)still turns the check off. - Garbage could leave a connection unable to make an allocation that fits in its memory limit, on every try. Two cases were missed by the collection the 1.4.0 entry describes. An allocation too large to fit is refused by the engine before it is made, so the memory in use never comes within the 64 KB that triggered a collection: under the 64 MB default, with 40 MB of cyclic garbage that nothing referenced any more,
new ArrayBuffer(30 * 1024 * 1024)failed every time it was tried. Garbage is now collected whenever the error is "out of memory", so the next try succeeds. And a lower limit set above the memory in use left the garbage of the old limit counting against the new one: with the garbage of 200,000 cyclic objects and the limit lowered from none to 32 MB,new ArrayBuffer(16 * 1024 * 1024)failed, where it worked without the garbage.js_set_memory_limit()now always collects, which is cheap because it is rare and no JavaScript is running then. - A
db.exec()result set dropped partway through a query that computes a JavaScript window function crashed the process. The statement still held the function's state, so finalizing it ran the function'sfinal, which is JavaScript, from inside the engine's own freeing of the result set object, where JavaScript must not run: when thatfinalallocated, it could start a garbage collection that freed the very object being freed. In thesqlite3shell this ended with "double free or corruption" or with a segmentation fault, and 60 turns of a loop that drops such a result set were enough. A statement that is not mid-query holds no such state and is still finalized there; a busy one is now ended where JavaScript may run. Reported as issue #25. - A
db.exec()result set that JavaScript kept, in a global say, leaked the whole connection. Its statement stayed open, sosqlite3_close()returned SQLITE_BUSY and never closed the connection, andsqlite3_close_v2()left it behind for good: only closing frees the JavaScript runtime, and only freeing the runtime frees the result set that holds the statement. About 63 KB of SQLite memory went with each connection, plus the runtime's own. No result set now outlives the call into JavaScript that created it, so nothing keeps a connection from closing. - An interrupt left a connection unable to run anything when JavaScript held an open
db.exec()result set. SQLite keeps an interrupt in effect until no statement of the connection is running, and a result set that JavaScript leaves open is a running statement. So interrupting JavaScript that held one — kept in a global, or garbage not yet collected — made every later statement on the connection fail with "interrupted", including the JavaScript that could have released it, until the connection was closed. In thesqlite3shell, Ctrl-C duringglobalThis.held = db.exec("SELECT 1 UNION ALL SELECT 2"); held.next(); while (true) {}left the session that way. Each connection now lists its result sets and ends the ones still open when the interrupted call into JavaScript returns. A result set that JavaScript kept across an interrupt now throws "interrupted" fromnext()andtoArray(), rather than reporting the end of its rows as it would have, and the interrupt then clears as usual once the interrupted statement ends. This needs SQLite 3.41.0 or later, as the interrupt handler does.
- Node.js: the package could not load the extension when imported as an ES module.
import { getExtensionPath } from '@sqliteai/sqlite-js', as in the README, threwExtensionNotFoundErrorsaying the platform package (for example@sqliteai/sqlite-js-linux-x86_64) was not installed, even when it was. The ESM build could not userequireto load the platform package, and the real error was discarded. The package now loads correctly from native ES modules, from CommonJS, and from esbuild and webpack bundles in both CommonJS and ESM output, including webpack bundles of the CommonJS build, which also failed before. - Node.js: errors that prevented the platform package from loading were hidden.
ExtensionNotFoundErrornow says "not installed" only when the platform package is actually missing. Any other error raised while loading it is included in the message and available as the error'scause, and a platform package whose binary is missing gets its own message.
Four changes in this release can alter the behavior of SQL that works on 1.3.7. JavaScript now has a
memory limit, 64 MB by default, where it had none, so code that allocates more than that fails with
"out of memory" until the limit is raised — see js_set_memory_limit() under Added. The other
three are under Changed: the functions that run JavaScript can no longer be called from views,
triggers and other schema objects stored in the database; a whole number that came back as REAL now
comes back as INTEGER; and js_set_max_stack_size() rejects a size larger than the calling thread's
stack.
js_set_memory_limit(): sets the most memory, in bytes, that JavaScript may allocate on a connection, with 0 meaning no limit. There is now a default limit of 64 MB, where memory was previously unbounded and runaway JavaScript could exhaust the process. This can stop SQL that works today: code that legitimately allocates more than 64 MB, such as one large string or buffer built in JavaScript, now fails with "out of memory". Calljs_set_memory_limit(0)for the old unbounded behavior, or a larger figure for a bound you choose, and build with-DSQLITE_JS_DEFAULT_MEMORY_LIMIT=bytesto change the default. Reaching the limit leaves the connection usable rather than breaking it: garbage is collected before the limit is reached and as the limit changes, so a new limit below what a connection has already allocated still leaves it working. A limit below the memory that is still in use, such as a large value held in a global, is the one case that blocks further allocation until the limit is raised again.sqlite3_interrupt()now stops running JavaScript: the statement fails with an "interrupted" error, even if the JavaScript catches exceptions, and Ctrl-C in thesqlite3shell does this. Previously no interrupt handler was installed, so JavaScript ran to the end on its own terms and a loop such asfor (;;) {}could only be stopped by killing the process. This needs SQLite 3.41.0 or later, which addedsqlite3_is_interrupted(); against an older library the extension loads and behaves as before.ArrayBufferand typed array values become BLOBs. A function that returnednew Uint8Array([1, 2, 3])or anArrayBufferpreviously produced NULL, so a function could not even give back the BLOB it was handed: a BLOB argument arrives as anArrayBuffer, but(function (args) { return args[0]; })turnedx'0102'into NULL. Typed arrays are now accepted asdb.exec()parameters too, where they previously bound NULL, and a typed array uses its own byte range, so a view onto part of a buffer is just that part.
- The functions that run JavaScript are registered
SQLITE_DIRECTONLY. Every function this extension registers exceptjs_versionnow runs only from top-level SQL: a view, trigger, CHECK constraint, generated column or index stored in the database can no longer call it, and fails with an error such as "unsafe use of js_eval()". Previously a database file from an untrusted source could run arbitrary JavaScript, read files throughjs_load_text()or change the runtime simply by being queried. TEMP views and triggers are unaffected, since only the connection itself can create them, and the functions you create withjs_create_scalar(),js_create_aggregate(),js_create_window()andjs_create_collation()are not given the flag, so a stored view or trigger can still call those. If you keepjs_*calls in a stored view or trigger, move them into top-level SQL or recreate the object as TEMP. A database can still hold JavaScript in itsjs_functionstable, whichjs_init_table(1)runs, so call that only on databases you trust. - Whole numbers are returned as INTEGER. A number from JavaScript now becomes an INTEGER if its value is a whole number that
Number.isSafeInteger()accepts, from -(2^53 - 1) to 2^53 - 1, and a REAL otherwise. The result previously followed the value's internal representation in the engine rather than the value itself, which was inconsistent: a function returning its REAL argument unchanged gave back REAL3.0, while one computing6 / 2gave the INTEGER3. The same SQL can therefore now reportintegerwhere it reportedreal— note that a REAL column holding3.0round-trips through JavaScript as the INTEGER3, because JavaScript has only one number type. js_set_max_stack_size()rejects a size larger than the calling thread's stack, reporting the largest size allowed, where it previously accepted any value. A size beyond the real stack is no limit at all: QuickJS's check would never trip and code that calls itself without end would crash the process instead of failing with "Maximum call stack size exceeded".
- Exceptions thrown by an aggregate's or a window function's
steporinversewere discarded, producing wrong results with no error. An aggregate whosestepthrew on one row silently skipped that row and returned a plausible value for the rest; the statement now fails with the exception's message. - Errors raised while a
db.exec()result set runs were discarded. A constraint failure reported bynext()ortoArray()was not thrown, so JavaScript that inserted a conflicting row saw a successful call and no row inserted. Such errors are now thrown, as an error in the SQL itself is already thrown fromdb.exec(). - A buffer whose bytes could not be read became NULL instead of an error. A detached
ArrayBufferpassed todb.exec()bound SQL NULL and reported success; it now fails with "ArrayBuffer is detached". The same holds for a typed array whose view no longer falls inside its buffer, after the buffer was detached or resized, in a parameter or in a function's result. - Deep recursion in JavaScript could crash the process instead of failing with "Maximum call stack size exceeded". The engine's 1 MB default stack was used however much stack the calling thread actually had, so a thread with less — a pthread created with the 512 KB default on macOS, for instance — overflowed its real stack first. Each call into JavaScript now measures the stack of the thread it runs on and lowers the size to fit, keeping a margin for the native code that runs between the engine's checks, so a connection used from several threads is safe on all of them.
- Flutter package publishing: the
LICENSEsymlink inside the Flutter package still pointed at theLICENSE.mdthat was replaced byLICENSE, sodart pub publishrejected the package and 1.3.6 never reached pub.dev. The Flutter package is published again from this release, which also carries every fix listed under 1.3.6.
- Crashes when loading a function definition with missing code: a row in the JavaScript functions table whose
step_codeorfinal_codewasNULLdereferenced a NULL pointer and crashed the process onjs_init_table(1). The code required by each function kind is now validated before use. - Out-of-bounds read when the JavaScript functions table has an unexpected layout: the loader selected every column and trusted their order and count, reading past the end of the result in release builds, where the assertion that guarded it is compiled out. It now selects its seven columns explicitly and aborts with a clear error if they do not match.
- Use-after-free when extension initialization failed: the global JavaScript context was released twice, because SQLite already invokes the destructor callback when registering a function fails. Depending on where the failure happened this either touched freed memory or leaked the whole JavaScript runtime.
- Leak when registering a collation failed: unlike
sqlite3_create_function_v2(),sqlite3_create_collation_v2()does not invoke the destructor callback on failure, so the function context and the reference it held on the JavaScript runtime were never released. - Unknown function kinds silently reported success: a definition whose kind was not
scalar,aggregate,windoworcollationregistered nothing, leaked its context and still returnedSQLITE_OK. It is now rejected with an explicit error. js_load_text()/js_load_blob()on an empty file reported "out of memory" instead of returning an empty result. A failingfseek()orftell()is now reported as a real error, and a file too large for SQLite's maximum length is reported as too big.js_load_text()on files with CRLF line endings could fail on Windows, where the file size and the number of bytes actually read legitimately differ in text mode.- Invalid
valueorinversecode in a window function was accepted when the function was created and only failed at the first query. All of a window function's code is now validated at creation time. - Collations returning a fractional value such as
-0.5were treated as "equal", so no ordering took place; only the sign of the returned value is now considered. A collation that throws or returns a non-number now consistently answers "equal" instead of "less than", which could produce wrong orderings. - Unhelpful
Rowseterrors: an out-of-range column index, or use after the last row, reported "Unknown JavaScript exception" instead of describing the problem. - Error reporting from
js_init_table(1): a detailed error was replaced by a bare error code, and attempting to update an already-registered function reported the error code as its message.
- The extension now builds without warnings under
-Wall -Wextra. - The npm platform packages now ship the
LICENSEfile from the repository root, and declareApache-2.0as their license. They previously referenced aLICENSE.mdthat no longer exists, which aborted the release before any package was published. The remaining references to the Elastic License 2.0 in the Node and Flutter packages were updated to match the Apache License 2.0 the project ships.
Not released. The release pipeline failed before publishing, so this version exists only as an Android artifact on Maven Central. Superseded by 1.3.6.
- Flutter package publishing: the pub.dev release now ships the complete set of native libraries.
- Swift Package on Xcode 26: the package now uses a binary target with a versioned macOS framework, fixing build failures for apps that depend on
sqlite-jsvia Swift Package Manager.
- Flutter package on iOS: iOS device and simulator binaries are now shipped as separate slices, so Flutter apps build and run correctly on both.
- Parameter binding in
db.exec(): values can now be passed as extra arguments and are bound to the statement's placeholders — e.g.db.exec("SELECT ? AS a, ? AS b", 42, "hello"). Supported types arenull, numbers,BigInt, booleans, strings andArrayBuffer. Previously all placeholders were left unbound. BigIntreturn values from JavaScript functions are now converted to SQLite INTEGER instead of silently becomingNULL.- String exceptions (
throw "message") now surfacemessageas the SQL error text instead of a generic error.
- Updated the embedded QuickJS engine to 0.12.1, including support for import attributes.
- Crashes when an aggregate or window function failed to initialize: SQLite still invokes the final/value/inverse callbacks after a failed step, which dereferenced a NULL context and crashed the process.
- Crashes when using a
Rowsetafter it was finalized (next(),get(),name(),toArray()). js_load_text()/js_load_blob()on files larger than one byte always failed to load due to a wrongfread()argument order.- Redundant writes to the JavaScript functions table: the duplicate check never matched, so every call rewrote the row. A failure while preparing the write could also lead to undefined behavior.
- Wrong error reported for window functions: an error raised in
valuewas reported as coming fromfinal, and an error ininverseas coming fromstep. - Memory leaks on extension initialization failure and when the JavaScript runtime could not be created.
- Flutter package: native libraries are now included in the published pub.dev package.
- Flutter package with prebuilt native libraries for all supported platforms.
- Android 15+ compatibility: the Android libraries are now built with 16 KB page size support, required by recent devices and by Google Play.
- Node package
@sqliteai/sqlite-js, shipping the prebuilt extension for Node.js projects.
- Memory leak when the initialization code of an aggregate function failed to evaluate.
- Android AAR package, so the extension can be added to Android projects as a Gradle dependency.
- Swift Package Manager support: the repository can be added directly as a package dependency in Xcode projects.
- Apple
xcframeworkand musl (Alpine/static) builds. macOS and iOS binaries are now signed and notarized.
- The license now explicitly grants usage for open-source projects.
- Linux builds failing to link against the math library.
js_set_max_stack_size()to configure the JavaScript engine stack limit. Set it to0when the same database connection or runtime is used from multiple threads, to avoid spurious "stack overflow" errors.
- Memory leaks when a JavaScript function raised an error.
- Window function state leaking between invocations: the aggregate context was not reset between separate calls, so results could be affected by a previous query. Related memory leaks in the JavaScript context were also fixed.
- Crash on shutdown caused by an incorrect teardown order of the JavaScript runtime.
- Android and Apple builds producing binaries for the wrong architectures.
- Android and iOS binaries to the official releases.
Initial public release.
- Custom SQLite functions written in JavaScript:
js_create_scalar(),js_create_aggregate(),js_create_window()andjs_create_collation(). js_eval()to evaluate arbitrary JavaScript from SQL, andjs_load_text()/js_load_blob()to load code from a file.js_init_table()to persist JavaScript functions inside the database, so they are automatically restored — and can be synced across devices — when the database is opened.dbglobal object to query the current database from JavaScript, together with theRowsetclass for iterating results.js_version()to retrieve the extension version.- Prebuilt binaries for Linux (x86/ARM), macOS (x86/ARM) and Windows.