mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-28 12:35:08 +02:00
fix(sdk-js): non-ok response is not throwing anymore
This commit is contained in:
@@ -165,8 +165,7 @@ class BaseClient {
|
||||
signal?: AbortSignal;
|
||||
},
|
||||
): Promise<T> {
|
||||
const response = await this.asyncCaller.call(
|
||||
_getFetchImplementation(),
|
||||
const response = await this.asyncCaller.fetch(
|
||||
...this.prepareFetchOptions(path, options),
|
||||
);
|
||||
if (response.status === 202 || response.status === 204) {
|
||||
@@ -784,8 +783,7 @@ export class RunsClient<
|
||||
|
||||
const endpoint =
|
||||
threadId == null ? `/runs/stream` : `/threads/${threadId}/runs/stream`;
|
||||
const response = await this.asyncCaller.call(
|
||||
_getFetchImplementation(),
|
||||
const response = await this.asyncCaller.fetch(
|
||||
...this.prepareFetchOptions(endpoint, {
|
||||
method: "POST",
|
||||
json,
|
||||
@@ -1077,8 +1075,7 @@ export class RunsClient<
|
||||
? { signal: options }
|
||||
: options;
|
||||
|
||||
const response = await this.asyncCaller.call(
|
||||
_getFetchImplementation(),
|
||||
const response = await this.asyncCaller.fetch(
|
||||
...this.prepareFetchOptions(`/threads/${threadId}/runs/${runId}/stream`, {
|
||||
method: "GET",
|
||||
timeoutMs: null,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import pRetry from "p-retry";
|
||||
import PQueueMod from "p-queue";
|
||||
import { _getFetchImplementation } from "../singletons/fetch.js";
|
||||
|
||||
const STATUS_NO_RETRY = [
|
||||
400, // Bad Request
|
||||
@@ -210,7 +211,8 @@ export class AsyncCaller {
|
||||
}
|
||||
|
||||
fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {
|
||||
const fetchFn = this.customFetch ?? fetch;
|
||||
const fetchFn =
|
||||
this.customFetch ?? (_getFetchImplementation() as typeof fetch);
|
||||
return this.call(() =>
|
||||
fetchFn(...args).then((res) => (res.ok ? res : Promise.reject(res))),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user