mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-12 04:37:51 +02:00
Don't enforce timeouts for run stream / block endpoints
This commit is contained in:
+16
-14
@@ -45,8 +45,6 @@ class BaseClient {
|
||||
|
||||
protected timeoutMs: number;
|
||||
|
||||
protected runTimeoutMs: number;
|
||||
|
||||
protected apiUrl: string;
|
||||
|
||||
protected defaultHeaders: Record<string, string | null | undefined>;
|
||||
@@ -62,7 +60,6 @@ class BaseClient {
|
||||
|
||||
// default limit being capped by Chrome
|
||||
// https://github.com/nodejs/undici/issues/1373
|
||||
this.runTimeoutMs = config?.timeoutMs || 300_000;
|
||||
this.apiUrl = config?.apiUrl || "http://localhost:8123";
|
||||
this.defaultHeaders = config?.defaultHeaders || {};
|
||||
if (config?.apiKey != null) {
|
||||
@@ -75,7 +72,7 @@ class BaseClient {
|
||||
options?: RequestInit & {
|
||||
json?: unknown;
|
||||
params?: Record<string, unknown>;
|
||||
timeoutMs?: number;
|
||||
timeoutMs?: number | null;
|
||||
},
|
||||
): [url: URL, init: RequestInit] {
|
||||
const mutatedOptions = {
|
||||
@@ -92,10 +89,16 @@ class BaseClient {
|
||||
delete mutatedOptions.json;
|
||||
}
|
||||
|
||||
mutatedOptions.signal = mergeSignals(
|
||||
AbortSignal.timeout(options?.timeoutMs ?? this.timeoutMs),
|
||||
mutatedOptions.signal,
|
||||
);
|
||||
let timeoutSignal: AbortSignal | null = null;
|
||||
if (typeof options?.timeoutMs !== "undefined") {
|
||||
if (options.timeoutMs != null) {
|
||||
timeoutSignal = AbortSignal.timeout(options.timeoutMs);
|
||||
}
|
||||
} else {
|
||||
timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
||||
}
|
||||
|
||||
mutatedOptions.signal = mergeSignals(timeoutSignal, mutatedOptions.signal);
|
||||
const targetUrl = new URL(`${this.apiUrl}${path}`);
|
||||
|
||||
if (mutatedOptions.params) {
|
||||
@@ -120,7 +123,7 @@ class BaseClient {
|
||||
options?: RequestInit & {
|
||||
json?: unknown;
|
||||
params?: Record<string, unknown>;
|
||||
timeoutMs?: number;
|
||||
timeoutMs?: number | null;
|
||||
signal?: AbortSignal;
|
||||
},
|
||||
): Promise<T> {
|
||||
@@ -703,7 +706,7 @@ export class RunsClient extends BaseClient {
|
||||
...this.prepareFetchOptions(endpoint, {
|
||||
method: "POST",
|
||||
json,
|
||||
timeoutMs: this.runTimeoutMs,
|
||||
timeoutMs: null,
|
||||
signal: payload?.signal,
|
||||
}),
|
||||
);
|
||||
@@ -780,7 +783,6 @@ export class RunsClient extends BaseClient {
|
||||
return this.fetch<Run>(`/threads/${threadId}/runs`, {
|
||||
method: "POST",
|
||||
json,
|
||||
timeoutMs: this.runTimeoutMs,
|
||||
signal: payload?.signal,
|
||||
});
|
||||
}
|
||||
@@ -853,7 +855,7 @@ export class RunsClient extends BaseClient {
|
||||
return this.fetch<ThreadState["values"]>(endpoint, {
|
||||
method: "POST",
|
||||
json,
|
||||
timeoutMs: this.runTimeoutMs,
|
||||
timeoutMs: null,
|
||||
signal: payload?.signal,
|
||||
});
|
||||
}
|
||||
@@ -934,7 +936,7 @@ export class RunsClient extends BaseClient {
|
||||
options?: { signal?: AbortSignal },
|
||||
): Promise<void> {
|
||||
return this.fetch<void>(`/threads/${threadId}/runs/${runId}/join`, {
|
||||
timeoutMs: this.runTimeoutMs,
|
||||
timeoutMs: null,
|
||||
signal: options?.signal,
|
||||
});
|
||||
}
|
||||
@@ -957,7 +959,7 @@ export class RunsClient extends BaseClient {
|
||||
const response = await this.asyncCaller.fetch(
|
||||
...this.prepareFetchOptions(`/threads/${threadId}/runs/${runId}/stream`, {
|
||||
method: "GET",
|
||||
timeoutMs: this.runTimeoutMs,
|
||||
timeoutMs: null,
|
||||
signal,
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user