Skip to content

Commit cefa7cc

Browse files
claudeericallam
authored andcommitted
fix: throw error when input streams are used without v2 realtime streams
Instead of silently hanging, on() and once() now throw immediately with a clear error message telling the developer to enable v2RealtimeStreams. https://claude.ai/code/session_01SJHJts7r2yAxmoKLLz8vpc
1 parent eb2f0a2 commit cefa7cc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/core/src/v3/inputStreams/manager.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export class StandardInputStreamManager implements InputStreamManager {
4141
}
4242

4343
on(streamId: string, handler: InputStreamHandler): { off: () => void } {
44+
this.#requireV2Streams();
45+
4446
let handlerSet = this.handlers.get(streamId);
4547
if (!handlerSet) {
4648
handlerSet = new Set();
@@ -71,6 +73,8 @@ export class StandardInputStreamManager implements InputStreamManager {
7173
}
7274

7375
once(streamId: string, options?: InputStreamOnceOptions): Promise<unknown> {
76+
this.#requireV2Streams();
77+
7478
// Lazily connect the tail on first listener registration
7579
this.#ensureTailConnected();
7680

@@ -170,8 +174,16 @@ export class StandardInputStreamManager implements InputStreamManager {
170174
this.buffer.clear();
171175
}
172176

177+
#requireV2Streams(): void {
178+
if (this.currentRunId && this.streamsVersion !== "v2") {
179+
throw new Error(
180+
"Input streams require v2 realtime streams. Enable them with: { future: { v2RealtimeStreams: true } }"
181+
);
182+
}
183+
}
184+
173185
#ensureTailConnected(): void {
174-
if (!this.tailAbortController && this.currentRunId && this.streamsVersion === "v2") {
186+
if (!this.tailAbortController && this.currentRunId) {
175187
this.connectTail(this.currentRunId);
176188
}
177189
}

0 commit comments

Comments
 (0)