Commit 3b72191
authored
Prevent duplicate resume continuation on unary request (#340)
Issue #333 reported an issue where the continuation in the
`UnaryAsyncWrapper` was getting resumed twice, which results in a fatal
error. Additional details are available in the issue, but the gist is -
When the client is configured to use the gRPC protocol (therefore using
swift-nio for networking instead of URLSession), and it is configured
with a short timeout internal, when the server responds in error at
around the same time that the timeout occurs, the callback that resumes
the continuation may fire twice.
I was able to replicate this issue by adjusting the Eliza app's
`ProtocolClient` to have a timeout of 0.25s and to point Eliza at a
different Connect server (my own team's), such that requests to the
Eliza RPCs would result in 404 errors.
This change simply introduces a thread-safe `Bool` to track whether the
continuation has been resumed, and if the callback attempts to fire
twice, it will throw an `assertionFailure` and return instead of calling
`resume` again and causing a fatal error.
Closes #333
---------
Signed-off-by: Eddie Seay <[email protected]>1 parent 6535324 commit 3b72191
File tree
2 files changed
+38
-12
lines changed- .github/workflows
- Libraries/Connect/Internal/Unary
2 files changed
+38
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
| |||
Lines changed: 37 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | | - | |
51 | | - | |
52 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
53 | 73 | | |
| 74 | + | |
| 75 | + | |
54 | 76 | | |
55 | 77 | | |
56 | | - | |
57 | | - | |
58 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
59 | 85 | | |
60 | 86 | | |
0 commit comments