fix: clear race timeout after plugin loading settles

This commit is contained in:
YeonGyu-Kim 2026-02-07 17:31:01 +09:00
parent 050e6a2187
commit c2dfcadbac

View File

@ -120,15 +120,19 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
if (pluginsEnabled) { if (pluginsEnabled) {
const timeoutMs = pluginConfig.experimental?.plugin_load_timeout_ms ?? 10000; const timeoutMs = pluginConfig.experimental?.plugin_load_timeout_ms ?? 10000;
try { try {
const timeoutPromise = new Promise<never>((_, reject) => let timeoutId: ReturnType<typeof setTimeout>;
setTimeout(() => reject(new Error(`Plugin loading timed out after ${timeoutMs}ms`)), timeoutMs) const timeoutPromise = new Promise<never>((_, reject) => {
); timeoutId = setTimeout(
() => reject(new Error(`Plugin loading timed out after ${timeoutMs}ms`)),
timeoutMs,
);
});
pluginComponents = await Promise.race([ pluginComponents = await Promise.race([
loadAllPluginComponents({ loadAllPluginComponents({
enabledPluginsOverride: pluginConfig.claude_code?.plugins_override, enabledPluginsOverride: pluginConfig.claude_code?.plugins_override,
}), }),
timeoutPromise, timeoutPromise,
]); ]).finally(() => clearTimeout(timeoutId));
} catch (error) { } catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error); const errorMessage = error instanceof Error ? error.message : String(error);
log("[config-handler] Plugin loading failed", { error: errorMessage }); log("[config-handler] Plugin loading failed", { error: errorMessage });