Skip to content

drizzle-orm + better-sqlite3 fails to link: undefined _js_pg_client_new from drizzle/better-sqlite3/driver.js #602

Description

@proggeramlug

Summary

A minimal drizzle-orm fixture using the better-sqlite3 driver (no postgres dep at all) fails at link time with Undefined symbols: _js_pg_client_new referenced from node_modules/drizzle-orm/better-sqlite3/driver.js. The pg-driver code path is reachable from the better-sqlite3 entry but its FFI symbol isn't being linked in.

Reproducer

tests/release/packages/drizzle-sqlite/ fixture (added to the release-sweep harness this cycle):

// entry.ts
import { drizzle } from "drizzle-orm/better-sqlite3";
import { sqliteTable, integer, text } from "drizzle-orm/sqlite-core";
import { eq } from "drizzle-orm";
import Database from "better-sqlite3";

const sqlite = new Database(":memory:");
const db = drizzle(sqlite);

const users = sqliteTable("users", {
    id: integer("id").primaryKey(),
    name: text("name").notNull(),
    age: integer("age").notNull(),
});

sqlite.exec(`CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT NOT NULL, age INTEGER NOT NULL)`);
db.insert(users).values([{ id: 1, name: "alice", age: 30 }]).run();
const all = db.select().from(users).all();
console.log(`count=${all.length}`);
{
  "dependencies": { "drizzle-orm": "^0.36.0", "better-sqlite3": "^11.0.0" },
  "perry": { "compilePackages": ["drizzle-orm"] }
}
perry compile entry.ts -o out

Linker error tail

Linking (with stdlib)...
Undefined symbols for architecture arm64:
  "_js_pg_client_new", referenced from:
      _perry_fn_node_modules_drizzle_orm_better_sqlite3_driver_js__drizzle in node_modules_drizzle_orm_better_sqlite3_driver_js.o
      _perry_fn_node_modules_drizzle_orm_better_sqlite3_driver_js__drizzle in node_modules_drizzle_orm_better_sqlite3_driver_js.o
      _perry_fn_node_modules_drizzle_orm_better_sqlite3_driver_js__drizzle in node_modules_drizzle_orm_better_sqlite3_driver_js.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1
Error: Linking failed

Why this matters

Pure sqlite-only fixture; no pg import, no postgres backend in scope. Either drizzle's better-sqlite3 entry transitively imports pg code that codegen incorrectly emits FFI calls into, or perry's compilePackages emits FFI calls for symbols that the well-known-binding logic doesn't know to pull in.

Same root cause may affect any drizzle dialect that lives alongside other dialects in the npm package's source tree.

Environment

  • Perry 0.5.699
  • drizzle-orm ^0.36.0, better-sqlite3 ^11.0.0
  • macOS 26.4 / arm64
  • Discovered via scripts/release_sweep.sh --tier=3 (tests/release/packages/drizzle-sqlite/)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed defect or regressionparityCompatibility gap with Node.js, ECMAScript, or the supported ecosystem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions