Skip to content

error.response is only populated when callerOptions.onFailedResponseHook is configured #2632

Description

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).

Example Code

To reproduce:

const client = new Client({ apiUrl: "http://localhost:2024" });
try {
  await client.threads.get("nonexistent-thread");
} catch (err) {
  console.log(err.response); // undefined, even though the request failed with a real HTTP response
}

Environment: @langchain/langgraph-sdk, current main as of 2026-07-24

Error Message and Stack Trace (if applicable)

No response

Description

When an API call made through Client fails, the resulting error's .response property is undefined unless the client was configured with callerOptions.onFailedResponseHook.

This is because in libs/sdk/src/utils/async_caller.ts, HTTPError.fromResponse is called with includeResponse: !!onFailedResponseHook — the raw response is only attached as a side effect of registering that hook, which is meant for something else (e.g. logging/telemetry on failure), not for consumers who just want to inspect the response on error.

Expected behavior: There should be an explicit, independent option (e.g. callerOptions.includeResponseOnError or simply always attaching error.response) so callers can access the failed response without having to register an unrelated hook.

System Info

this is on latest right now

Activity

  1. kinKingen commented on Aug 6, 2026

    @kinKingen

    I'd like to take this if maintainers are happy to assign it.

    I checked current main at 6ac60da; libs/sdk/src/utils/async_caller.ts is blob 22299f2, identical to the locally exercised file. An offline minimal reproduction with AsyncCaller({ maxRetries: 0 }) rejecting a real Response("missing", { status: 404 }) produced:

    {"name":"HTTPError","status":404,"text":"missing","responseIsUndefined":true}

    No server or provider credentials are required. I also verified there is currently no assignee, linked branch/PR, or PR referencing #2632.

    Proposed focused change after assignment:

    • decouple response retention from onFailedResponseHook while preserving the hook and retry behavior;
    • add a regression asserting the thrown HTTP error retains the failed Response without configuring the hook, plus coverage that the hook path remains unchanged;
    • run the focused async_caller suite, SDK unit suite, build, lint, and format checks.

    I will wait for assignment before changing code, per CONTRIBUTING.md.

    AI assistance disclosure: I used OpenAI Codex to inspect the repository rules and current source and to run the offline reproduction. I personally reviewed the evidence, proposed scope, and this comment.

  2. added a commit that references this issue on Aug 10, 2026
    f9c0e88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions