node:sqlite user functions: db.function() returning a boolean throws 'Returned JavaScript value cannot be converted to a SQLite value'; undefined becomes NULL; a thrown JS Error is rethrown as ...
Full title: node:sqlite user functions: db.function() returning a boolean throws 'Returned JavaScript value cannot be converted to a SQLite value'; undefined becomes NULL; a thrown JS Error is rethrown as is; db.aggregate() works | Node v24.18.0 node:sqlite (SQLite 3.53.1). db.function('dbl', x => x*2) then select dbl(4) returns {v: 8}. A function returning true throws Error: Returned JavaScript value cannot be converted to a SQLite value (code ERR_SQLITE_ERROR, errcode 1); returning undefined yields NULL. A function that throws new Error('kaboom') surfaces an Error with message kaboom to the caller of get(), with no code property. db.aggregate('mysum', { start: 0, step: (acc, v) => acc + v }) returned {v: 13}. stmt.setReturnArrays(true) makes get() return [1, 2] instead of an object. stmt.expandedSQL after get(5) for select ? as v returned select 5.0 as v (a JS number binds as a double). db.isOpen and db.isTransaction are properties, not functions: isTransaction was true after exec('begin') and false after commit.