fix: suppress ExperimentalWarning for node:sqlite (#179) #180

Merged
xiaomo merged 1 commits from fix/179-suppress-experimental-warning into main 2026-04-27 08:20:32 +00:00
8 changed files with 47 additions and 1 deletions
+2
View File
@@ -1,3 +1,5 @@
import "@uncaged/nerve-core/experimental-warning-suppression.js";
import { defineCommand, runMain } from "citty";
import { consumeGlobalDaemonCliFlags } from "./cli-global.js";
+2
View File
@@ -1,3 +1,5 @@
import "@uncaged/nerve-core/experimental-warning-suppression.js";
import { runForegroundKernelSession } from "./run-foreground-kernel.js";
import { loadDaemonModule } from "./workspace-daemon.js";
+11
View File
@@ -3,6 +3,16 @@
"version": "0.4.0",
"type": "module",
"main": "dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./experimental-warning-suppression.js": {
"types": "./dist/experimental-warning-suppression.d.ts",
"default": "./dist/experimental-warning-suppression.js"
}
},
"files": ["dist"],
"publishConfig": {
"access": "public"
@@ -18,6 +28,7 @@
},
"devDependencies": {
"@rslib/core": "^0.21.3",
"@types/node": "^22.0.0",
"vitest": "^4.1.5"
}
}
+1
View File
@@ -10,6 +10,7 @@ export default defineConfig({
source: {
entry: {
index: "src/index.ts",
"experimental-warning-suppression": "src/experimental-warning-suppression.ts",
},
},
output: {
@@ -0,0 +1,23 @@
/**
* Patches `process.emit` so `ExperimentalWarning` (e.g. from `node:sqlite`) is not
* forwarded to the default handler. Other warning types are unchanged.
*
* Import this module before any code that loads `node:sqlite`.
*/
const WARNING_EVENT = "warning";
const EXPERIMENTAL_WARNING_NAME = "ExperimentalWarning";
type EmitFn = typeof process.emit;
const originalEmit = process.emit.bind(process) as EmitFn;
process.emit = ((event: string | symbol, ...args: unknown[]): boolean => {
if (event === WARNING_EVENT) {
const w = args[0];
if (w instanceof Error && w.name === EXPERIMENTAL_WARNING_NAME) {
return false;
}
}
return Reflect.apply(originalEmit, process, [event, ...args]) as boolean;
}) as EmitFn;
+2
View File
@@ -14,6 +14,8 @@
* nerve.yaml ← config
*/
import "@uncaged/nerve-core/experimental-warning-suppression.js";
import { readFileSync } from "node:fs";
import { join, resolve } from "node:path";
+2
View File
@@ -9,6 +9,8 @@
* workflows/<name>/index.ts (or .js) ← user workflow definition
*/
import "@uncaged/nerve-core/experimental-warning-suppression.js";
import { existsSync } from "node:fs";
import { join, resolve } from "node:path";
+4 -1
View File
@@ -58,9 +58,12 @@ importers:
'@rslib/core':
specifier: ^0.21.3
version: 0.21.3(typescript@5.9.3)
'@types/node':
specifier: ^22.0.0
version: 22.19.17
vitest:
specifier: ^4.1.5
version: 4.1.5(@types/node@25.6.0)(vite@8.0.9(@types/node@25.6.0)(esbuild@0.27.7)(yaml@2.8.3))
version: 4.1.5(@types/node@22.19.17)(vite@8.0.9(@types/node@22.19.17)(esbuild@0.27.7)(yaml@2.8.3))
packages/daemon:
dependencies: