Skip to content

Commit 0f59586

Browse files
committed
🤖 fix: reduce noisy tool errors on abort
Change-Id: I5cf741604f12af5586f6245ae890678405a402a7 Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 5e3929f commit 0f59586

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/node/services/providerService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export type { AWSCredentialStatus, ProviderConfigInfo, ProvidersConfigMap };
1515
export class ProviderService {
1616
private readonly emitter = new EventEmitter();
1717

18-
constructor(private readonly config: Config) {}
18+
constructor(private readonly config: Config) {
19+
// The provider config subscription may have many concurrent listeners (e.g. multiple windows).
20+
// Avoid noisy MaxListenersExceededWarning for normal usage.
21+
this.emitter.setMaxListeners(50);
22+
}
1923

2024
/**
2125
* Subscribe to config change events. Used by oRPC subscription handler.

src/node/services/streamManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,8 @@ export class StreamManager extends EventEmitter {
10231023
error: unknown;
10241024
};
10251025

1026-
log.error(`Tool execution error for '${toolErrorPart.toolName}'`, {
1026+
const logLevel = streamInfo.abortController.signal.aborted ? log.debug : log.error;
1027+
logLevel(`Tool execution error for '${toolErrorPart.toolName}'`, {
10271028
toolCallId: toolErrorPart.toolCallId,
10281029
error: toolErrorPart.error,
10291030
});

src/node/services/tools/task.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export const createTaskTool: ToolFactory = (config: ToolConfiguration) => {
1414
const workspaceId = requireWorkspaceId(config, "task");
1515
const taskService = requireTaskService(config, "task");
1616

17+
if (abortSignal?.aborted) {
18+
throw new Error("Interrupted");
19+
}
20+
1721
const modelString =
1822
config.muxEnv && typeof config.muxEnv.MUX_MODEL_STRING === "string"
1923
? config.muxEnv.MUX_MODEL_STRING

0 commit comments

Comments
 (0)