Skip to content

fix: prevent Hono from overriding global Response object (v1.x)#1411

Merged
mattzcarey merged 3 commits intov1.xfrom
fix/hono-override-global-objects-v1
Jan 20, 2026
Merged

fix: prevent Hono from overriding global Response object (v1.x)#1411
mattzcarey merged 3 commits intov1.xfrom
fix/hono-override-global-objects-v1

Conversation

@mattzcarey
Copy link
Copy Markdown
Contributor

@mattzcarey mattzcarey commented Jan 20, 2026

Summary

  • Pass overrideGlobalObjects: false to getRequestListener() calls in StreamableHTTPServerTransport
  • Prevents Hono from overwriting the global Response object
  • Adds tests to verify global Response is preserved after transport initialization

Problem

When StreamableHTTPServerTransport is instantiated, Hono's getRequestListener() overwrites the global Response object with its own implementation (by default). This breaks frameworks like Next.js whose NextResponse class extends the native Response, causing instanceof Response checks to fail.

Fixes #1369

Test plan

  • Added tests that verify global Response is not overwritten after transport construction
  • Added tests that verify global Response is not overwritten after handleRequest is called
  • All existing tests pass

@mattzcarey mattzcarey requested a review from a team as a code owner January 20, 2026 10:57
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 20, 2026

⚠️ No Changeset found

Latest commit: 3becbfc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Jan 20, 2026

Open in StackBlitz

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/sdk@1411

commit: 3becbfc

Pass `overrideGlobalObjects: false` to `getRequestListener()` calls in
StreamableHTTPServerTransport to prevent Hono from overwriting the
global Response object.

This fixes an issue where frameworks like Next.js whose response classes
extend the native Response would break after initializing MCP transport,
as `instanceof Response` checks would fail.

Also bumps @hono/node-server to ^1.19.9.

Fixes #1369
@mattzcarey mattzcarey force-pushed the fix/hono-override-global-objects-v1 branch from 5cd5d70 to 223d7ff Compare January 20, 2026 11:00
@mattzcarey mattzcarey enabled auto-merge (squash) January 20, 2026 11:16
@mattzcarey mattzcarey merged commit 6e8f7e1 into v1.x Jan 20, 2026
7 checks passed
@mattzcarey mattzcarey deleted the fix/hono-override-global-objects-v1 branch January 20, 2026 11:17
sgmakgg added a commit to boringstudio-org/mcp-gitea that referenced this pull request Mar 13, 2026
…#17)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@modelcontextprotocol/sdk](https://modelcontextprotocol.io) ([source](https://github.com/modelcontextprotocol/typescript-sdk)) | dependencies | patch | [`1.25.2` → `1.25.3`](https://renovatebot.com/diffs/npm/@modelcontextprotocol%2fsdk/1.25.2/1.25.3) |

---

### Release Notes

<details>
<summary>modelcontextprotocol/typescript-sdk (@&#8203;modelcontextprotocol/sdk)</summary>

### [`v1.25.3`](https://github.com/modelcontextprotocol/typescript-sdk/releases/tag/v1.25.3)

[Compare Source](modelcontextprotocol/typescript-sdk@v1.25.2...v1.25.3)

#### What's Changed

- \[v1.x backport] Use correct schema for client sampling validation when tools are present by [@&#8203;olaservo](https://github.com/olaservo) in [#&#8203;1407](modelcontextprotocol/typescript-sdk#1407)
- fix: prevent Hono from overriding global Response object (v1.x) by [@&#8203;mattzcarey](https://github.com/mattzcarey) in [#&#8203;1411](modelcontextprotocol/typescript-sdk#1411)

**Full Changelog**: <modelcontextprotocol/typescript-sdk@v1.25.2...v1.25.3>

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi45NC4zIiwidXBkYXRlZEluVmVyIjoiNDIuOTQuMyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->

Co-authored-by: Renovate Bot <renovate@boringstudio.by>
Co-authored-by: ChubbChubbs <sgmakgg@gmail.com>
Reviewed-on: https://git.boringstudio.by/BoringStudio/mcp-gitea/pulls/17
Co-authored-by: boring-bot <bot@boringstudio.by>
Co-committed-by: boring-bot <bot@boringstudio.by>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants