How Node.js SQLite works on Deno?
Hello, I'm curious how node:sqlite is supported in Deno? Basically you reflect the APIs exposed by Node.js? Or you get/fetch the code from Node.js and compile it to Deno? Because there are open issues in Node.js for SQLite and thought if those will be reflected in Deno once Node.js deploys them.
7 Replies
We don't fetch any code from Node. We basically polyfill the APIs and mirror the calls to the one Node specifies. The internals on how things work behind the scenes are different though. So if Nodejs has a bug in their sqlite module, that doesn't mean that Deno has it. Same is true for our code: We could theoretically have a bug that the nodejs version doesn't.
Thanks a lot @marvinh. 🙏🏼
if those will be reflected in Deno once Node.js deploys themIf you see a bug in Node.js, it might be interesting to test Deno's implementation to see if it's also present there. And I imagine the Deno team would appreciate a bug report if that's the case. I think one of the open issues/requests is for Node.js is to add async APIs, and I definitely hope Deno will implement that too once Node.js specifies the API. (Alternatively, I wouldn't mind Deno-specific async sqlite APIs, but I can see why it's simpler to just let Node design it so there aren't 2 to support.)
Thanks @CodyC yeah I found a bug some days ago present in both Node.js and Deno and they’ve been solved fortunately.
The announcement of node:sqlite piqued my interest. However, it seems only a subset of the node:sqlite APIs have been implemented, e.g. no support for loading extensions among other restrictions due to unresolved Deno sandboxing issues. It would be nice if the docs and/or announcements made note of this.
Good point, opened an issue for that https://github.com/denoland/docs/issues/1658
also related bug report on the deno tracker: https://github.com/denoland/deno/issues/29030
GitHub
node:sqlite unable to load extensions · Issue #29030 · denoland/deno
Version: Deno 2.3.0-rc.2+74425dd https://docs.deno.com/api/node/sqlite/~/DatabaseSync.prototype.loadExtension import { DatabaseSync } from "node:sqlite"; const db = new DatabaseSync('...