mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 17:51:22 +00:00
34 lines
1013 B
JavaScript
34 lines
1013 B
JavaScript
const warningFilterKey = Symbol.for("openclaw.warning-filter");
|
|
|
|
export function installProcessWarningFilter() {
|
|
if (globalThis[warningFilterKey]?.installed) {
|
|
return;
|
|
}
|
|
|
|
const originalEmitWarning = process.emitWarning.bind(process);
|
|
process.emitWarning = (...args) => {
|
|
const [warningArg, secondArg, thirdArg] = args;
|
|
const warning =
|
|
warningArg instanceof Error
|
|
? {
|
|
name: warningArg.name,
|
|
message: warningArg.message,
|
|
code: warningArg.code,
|
|
}
|
|
: {
|
|
name: typeof secondArg === "string" ? secondArg : secondArg?.type,
|
|
message: typeof warningArg === "string" ? warningArg : undefined,
|
|
code: typeof thirdArg === "string" ? thirdArg : secondArg?.code,
|
|
};
|
|
|
|
if (warning.code === "DEP0040" && warning.message?.includes("punycode")) {
|
|
return;
|
|
}
|
|
|
|
Reflect.apply(originalEmitWarning, process, args);
|
|
return;
|
|
};
|
|
|
|
globalThis[warningFilterKey] = { installed: true };
|
|
}
|