Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions native/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ashbyhq/libpg-query-native",
"version": "0.1.0",
"version": "0.1.1",
"description": "PostgreSQL query parser — native N-API + jemalloc backend",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down Expand Up @@ -48,10 +48,10 @@
"typescript": "5.9.3"
},
"optionalDependencies": {
"@ashbyhq/libpg-query-native-darwin-arm64": "0.1.0",
"@ashbyhq/libpg-query-native-linux-x64": "0.1.0",
"@ashbyhq/libpg-query-native-linux-arm64": "0.1.0",
"@ashbyhq/libpg-query-native-linux-x64-musl": "0.1.0",
"@ashbyhq/libpg-query-native-linux-arm64-musl": "0.1.0"
"@ashbyhq/libpg-query-native-darwin-arm64": "0.1.1",
"@ashbyhq/libpg-query-native-linux-x64": "0.1.1",
"@ashbyhq/libpg-query-native-linux-arm64": "0.1.1",
"@ashbyhq/libpg-query-native-linux-x64-musl": "0.1.1",
"@ashbyhq/libpg-query-native-linux-arm64-musl": "0.1.1"
}
}
24 changes: 19 additions & 5 deletions native/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,27 @@ function loadNativeAddon(): NativeAddon {

function isMusl(): boolean {
if (process.platform !== "linux") return false;
// Prefer Node's own libc marker: `glibcVersionRuntime` is set on glibc and
// absent on musl. This is reliable in minimal images (distroless/scratch)
// that ship no `ldd` binary — shelling out there throws and would otherwise
// be misread as musl, selecting the wrong platform package.
try {
const { execSync } = require("child_process");
const ldd = execSync("ldd --version 2>&1", { encoding: "utf8" });
return ldd.includes("musl");
const report = process.report?.getReport?.() as
| { header?: { glibcVersionRuntime?: string } }
| undefined;
if (report?.header != null) {
return report.header.glibcVersionRuntime == null;
}
} catch {
// ldd --version exits non-zero on musl
return true;
// fall through to the filesystem probe
}
// Fallback (older runtimes without process.report): look for the musl
// dynamic loader on disk. Default to glibc — the common case — when unsure.
try {
const fs = require("fs");
return fs.readdirSync("/lib").some((f: string) => f.startsWith("ld-musl-"));
} catch {
return false;
}
}

Expand Down
Loading