src.nth.io/

summaryrefslogtreecommitdiff
path: root/src/warnings.ts
blob: 8bf2ca598525b59abfebbb243ba044f241a346ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
 * matter.js's storage backend imports node:sqlite, which Node still marks
 * experimental and announces with a process-level ExperimentalWarning on
 * every run. That one-line warning is pure noise to an operator, so exactly
 * that warning is dropped here; every other warning passes through.
 *
 * This module must be imported before anything that (transitively) imports
 * matter.js, because the warning fires when node:sqlite is first loaded.
 */

const originalEmitWarning = process.emitWarning.bind(process);

process.emitWarning = ((warning: string | Error, ...rest: unknown[]): void => {
  const text = typeof warning === "string" ? warning : warning.message;
  if (text.includes("SQLite is an experimental feature")) return;
  (originalEmitWarning as (warning: string | Error, ...rest: unknown[]) => void)(warning, ...rest);
}) as typeof process.emitWarning;

export {};