From 0aa98a8e3bfb21afb128bc9437d700dc5fe0b8a4 Mon Sep 17 00:00:00 2001 From: Brad Groux <3053586+BradGroux@users.noreply.github.com> Date: Fri, 3 Apr 2026 00:20:17 -0500 Subject: [PATCH] fix: import CHANNEL_IDS from leaf module to avoid TDZ on init (#48832) (#60061) schema.ts and validation.ts imported CHANNEL_IDS from channels/registry.js, which re-exports from channels/ids.js but also imports plugins/runtime.js. When the bundler resolves this dependency graph, the re-exported CHANNEL_IDS can be undefined at the point config/validation.ts evaluates (temporal dead zone), causing 'CHANNEL_IDS is not iterable' on startup. Fix: import CHANNEL_IDS directly from channels/ids.js (the leaf module with zero heavy dependencies) and normalizeChatChannelId from channels/chat-meta.js. Fixes #48832 Co-authored-by: Brad Groux --- src/config/schema.ts | 2 +- src/config/validation.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/config/schema.ts b/src/config/schema.ts index 31a6fb16a81..22600598b67 100644 --- a/src/config/schema.ts +++ b/src/config/schema.ts @@ -1,5 +1,5 @@ import crypto from "node:crypto"; -import { CHANNEL_IDS } from "../channels/registry.js"; +import { CHANNEL_IDS } from "../channels/ids.js"; import { GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA } from "./bundled-channel-config-metadata.generated.js"; import { GENERATED_BASE_CONFIG_SCHEMA } from "./schema.base.generated.js"; import type { ConfigUiHint, ConfigUiHints } from "./schema.hints.js"; diff --git a/src/config/validation.ts b/src/config/validation.ts index c9fa024bcea..3f732e6433d 100644 --- a/src/config/validation.ts +++ b/src/config/validation.ts @@ -1,6 +1,7 @@ import path from "node:path"; import { resolveAgentWorkspaceDir, resolveDefaultAgentId } from "../agents/agent-scope.js"; -import { CHANNEL_IDS, normalizeChatChannelId } from "../channels/registry.js"; +import { CHANNEL_IDS } from "../channels/ids.js"; +import { normalizeChatChannelId } from "../channels/chat-meta.js"; import { withBundledPluginAllowlistCompat } from "../plugins/bundled-compat.js"; import { listBundledWebSearchPluginIds } from "../plugins/bundled-web-search-ids.js"; import {