chore: filter noisy warnings

This commit is contained in:
Peter Steinberger
2026-01-24 10:48:33 +00:00
parent 3dcaa70531
commit 5482803547
4 changed files with 42 additions and 16 deletions

33
src/infra/warnings.ts Normal file
View File

@@ -0,0 +1,33 @@
const warningFilterKey = Symbol.for("clawdbot.warning-filter");
type Warning = Error & {
code?: string;
name?: string;
message?: string;
};
function shouldIgnoreWarning(warning: Warning): boolean {
if (warning.code === "DEP0040" && warning.message?.includes("punycode")) {
return true;
}
if (
warning.name === "ExperimentalWarning" &&
warning.message?.includes("SQLite is an experimental feature")
) {
return true;
}
return false;
}
export function installProcessWarningFilter(): void {
const globalState = globalThis as typeof globalThis & {
[warningFilterKey]?: { installed: boolean };
};
if (globalState[warningFilterKey]?.installed) return;
globalState[warningFilterKey] = { installed: true };
process.on("warning", (warning: Warning) => {
if (shouldIgnoreWarning(warning)) return;
process.stderr.write(`${warning.stack ?? warning.toString()}\n`);
});
}