Repository navigation
Commit 6d40d4c
committed
Close a failed listen stream only from the path that removed its entry
## Motivation and Context
When a `subscriptions/listen` stream's write fails, in notification delivery or in the acknowledgement write,
`StreamableHTTPTransport` removes the stream's registry entry and closes the stream. The close ran whether or
not the removal was this path's own: when the keepalive loop, a token expiry, or the transport teardown had
removed the entry a moment earlier, that path closes the stream too, and the failed write closed it a second time.
Every other removal path closes the stream only when it was the one to remove the entry.
The two write failure paths now do the same, so a stream is closed exactly once, by the path that removed it.
An acknowledgement skipped because the teardown marked the entry closed first went the same way, closing
a stream the teardown closes itself; that close is gone too.
## How Has This Been Tested?
A new test in `test/mcp/server/transports/streamable_http_transport_test.rb` fails a delivery write on a stream
whose entry another path removed just before, and counts the stream's closes: the delivery closes it once
against the previous library, and leaves it to the remover now.
A second test has the teardown mark an entry closed while its acknowledgement waits on the write mutex,
and counts one close instead of the two the previous library made.
## Breaking Changes
None.1 parent a391d32 commit 6d40d4c
2 files changed
Lines changed: 87 additions & 9 deletions
File tree
- lib/mcp/server/transports
- test/mcp/server/transports
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1204 | 1204 | | |
1205 | 1205 | | |
1206 | 1206 | | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
1211 | | - | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
1212 | 1210 | | |
1213 | | - | |
1214 | | - | |
| 1211 | + | |
1215 | 1212 | | |
1216 | 1213 | | |
1217 | 1214 | | |
| |||
1422 | 1419 | | |
1423 | 1420 | | |
1424 | 1421 | | |
1425 | | - | |
1426 | | - | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
1427 | 1425 | | |
1428 | 1426 | | |
1429 | 1427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6887 | 6887 | | |
6888 | 6888 | | |
6889 | 6889 | | |
| 6890 | + | |
| 6891 | + | |
| 6892 | + | |
| 6893 | + | |
| 6894 | + | |
| 6895 | + | |
| 6896 | + | |
| 6897 | + | |
| 6898 | + | |
| 6899 | + | |
| 6900 | + | |
| 6901 | + | |
| 6902 | + | |
| 6903 | + | |
| 6904 | + | |
| 6905 | + | |
| 6906 | + | |
| 6907 | + | |
| 6908 | + | |
| 6909 | + | |
| 6910 | + | |
| 6911 | + | |
| 6912 | + | |
| 6913 | + | |
| 6914 | + | |
| 6915 | + | |
| 6916 | + | |
| 6917 | + | |
| 6918 | + | |
| 6919 | + | |
| 6920 | + | |
| 6921 | + | |
| 6922 | + | |
| 6923 | + | |
| 6924 | + | |
| 6925 | + | |
| 6926 | + | |
| 6927 | + | |
| 6928 | + | |
| 6929 | + | |
| 6930 | + | |
| 6931 | + | |
| 6932 | + | |
| 6933 | + | |
| 6934 | + | |
| 6935 | + | |
| 6936 | + | |
| 6937 | + | |
| 6938 | + | |
| 6939 | + | |
6890 | 6940 | | |
6891 | 6941 | | |
6892 | 6942 | | |
| |||
7061 | 7111 | | |
7062 | 7112 | | |
7063 | 7113 | | |
| 7114 | + | |
| 7115 | + | |
| 7116 | + | |
| 7117 | + | |
| 7118 | + | |
| 7119 | + | |
| 7120 | + | |
| 7121 | + | |
| 7122 | + | |
| 7123 | + | |
| 7124 | + | |
| 7125 | + | |
| 7126 | + | |
| 7127 | + | |
| 7128 | + | |
| 7129 | + | |
| 7130 | + | |
| 7131 | + | |
| 7132 | + | |
| 7133 | + | |
| 7134 | + | |
| 7135 | + | |
| 7136 | + | |
| 7137 | + | |
| 7138 | + | |
| 7139 | + | |
| 7140 | + | |
| 7141 | + | |
| 7142 | + | |
| 7143 | + | |
7064 | 7144 | | |
7065 | 7145 | | |
7066 | 7146 | | |
| |||
0 commit comments