From 971ac0886b8891624eb40f2aab847b7e3fd5198a Mon Sep 17 00:00:00 2001 From: 0xRain Date: Fri, 13 Feb 2026 01:30:14 +0800 Subject: [PATCH] fix(cli): guard against read-only process.noDeprecation on Node.js v23+ (#14152) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 11bb9f141ae01d85c7eb8d4f8b526d7bda419558 Co-authored-by: 0xRaini <190923101+0xRaini@users.noreply.github.com> Co-authored-by: steipete <58493+steipete@users.noreply.github.com> Reviewed-by: @steipete --- src/cli/update-cli.ts | 4 ++-- src/cli/update-cli/suppress-deprecations.ts | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/cli/update-cli/suppress-deprecations.ts diff --git a/src/cli/update-cli.ts b/src/cli/update-cli.ts index c6f3dbd62..2d2d8ddfe 100644 --- a/src/cli/update-cli.ts +++ b/src/cli/update-cli.ts @@ -62,6 +62,7 @@ import { formatCliCommand } from "./command-format.js"; import { installCompletion } from "./completion-cli.js"; import { runDaemonRestart } from "./daemon-cli.js"; import { formatHelpExamples } from "./help-format.js"; +import { suppressDeprecations } from "./update-cli/suppress-deprecations.js"; export type UpdateCommandOptions = { json?: boolean; @@ -672,8 +673,7 @@ function printResult(result: UpdateRunResult, opts: PrintResultOptions) { } export async function updateCommand(opts: UpdateCommandOptions): Promise { - process.noDeprecation = true; - process.env.NODE_NO_WARNINGS = "1"; + suppressDeprecations(); const timeoutMs = opts.timeout ? Number.parseInt(opts.timeout, 10) * 1000 : undefined; const shouldRestart = opts.restart !== false; diff --git a/src/cli/update-cli/suppress-deprecations.ts b/src/cli/update-cli/suppress-deprecations.ts new file mode 100644 index 000000000..8912b5285 --- /dev/null +++ b/src/cli/update-cli/suppress-deprecations.ts @@ -0,0 +1,16 @@ +/** + * Suppress Node.js deprecation warnings. + * + * On Node.js v23+ `process.noDeprecation` may be a read-only property + * (defined via a getter on the prototype with no setter), so the + * assignment can throw. We fall back to the environment variable which + * achieves the same effect. + */ +export function suppressDeprecations(): void { + try { + process.noDeprecation = true; + } catch { + // read-only on Node v23+; NODE_NO_WARNINGS below covers this case + } + process.env.NODE_NO_WARNINGS = "1"; +}