Repository navigation
Commit dda52ff
committed
fix(server): commit the SSE response before the first event on GET
The streamable servlet's GET handler set the SSE headers, started async, and then
waited for the session to write something. The container only commits the response
when the first event is written, so a client that waits for the response before it
starts reading - Node's fetch/undici, mcp-remote - gave up on an idle server with
UND_ERR_HEADERS_TIMEOUT, retried twice, and ended up with no listening stream at all.
Flush the response right after startAsync so the status line and headers reach the
client immediately, the same way HttpServletMcpTransport does for the stateless
transport.
Refs #11551 parent 7b9b000 commit dda52ff
2 files changed
Lines changed: 52 additions & 0 deletions
File tree
- mcp-core/src/main/java/io/modelcontextprotocol/server/transport
- mcp-test/src/test/java/io/modelcontextprotocol/server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
664 | 665 | | |
665 | 666 | | |
666 | 667 | | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
667 | 710 | | |
668 | 711 | | |
669 | 712 | | |
| |||
0 commit comments