Commit 8d130aa
mcp: check ctx.Err() instead of Authorize error for cancellation
The cancellation check in streamableClientConn.Write inspected the
error returned by OAuthHandler.Authorize to decide whether the caller
abandoned the request. This failed for real-world handlers that return
a custom error rather than wrapping context.Canceled (e.g.
fmt.Errorf("oauth flow interrupted")).
Check ctx.Err() directly — it is the authoritative source for whether
the caller's context was cancelled, regardless of what Authorize
returns.
Update the regression test mock to return a non-wrapping error so it
exercises the real-world path. Verified: test fails (got 2 Authorize
calls) with the old errors.Is(err, ...) check, passes with ctx.Err().
Thanks to @smlx for identifying the bug and suggesting the fix.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 57e25f4 commit 8d130aa
2 files changed
Lines changed: 18 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1807 | 1807 | | |
1808 | 1808 | | |
1809 | 1809 | | |
1810 | | - | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
1811 | 1818 | | |
1812 | 1819 | | |
1813 | 1820 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1017 | 1017 | | |
1018 | 1018 | | |
1019 | 1019 | | |
1020 | | - | |
1021 | | - | |
1022 | | - | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
1023 | 1026 | | |
1024 | 1027 | | |
1025 | 1028 | | |
| |||
1036 | 1039 | | |
1037 | 1040 | | |
1038 | 1041 | | |
1039 | | - | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
1040 | 1046 | | |
1041 | 1047 | | |
1042 | 1048 | | |
| |||
0 commit comments