Commit 8f81127
committed
fix(graphql): guard query completer when stream emits multiple responses
QueryManager completed the same Completer on every Response from the link
stream. When the link emitted more than one event, the second completion
threw Bad state: Future already completed. Only complete the completer
while it is still pending, consistent with the onError path.
Reproduced when using a very short queryRequestTimeout (e.g. 1 ms) with
TimedInMemoryStore; that setup can emit multiple stream events and trigger
the crash. Example:
return GraphQLClient(
link: links,
cache: GraphQLCache(
store: TimedInMemoryStore(),
),
queryRequestTimeout: const Duration(milliseconds: 1),
);
Why merge: fixes a runtime crash for any setup where the link stream can
emit multiple values for a single query, and adds a regression test so the first emitted Response is kept when multiple emissions occur.1 parent 822a903 commit 8f81127
2 files changed
Lines changed: 39 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
292 | 298 | | |
293 | 299 | | |
294 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
45 | 71 | | |
46 | 72 | | |
0 commit comments