Commit 18c39e7
fix: correct SSE datasource complete behaviour (#1311)
- **fix: clean up SSE handler and properly handle complete**
- **test: new testSubscriptionUpdaterChan**
- **test: update SSE datasource tests to assert correct complete
behaviour**
<!--
Important: Before developing new features, please open an issue to
discuss your ideas with the maintainers. This ensures project alignment
and helps avoid unnecessary work for you.
Thank you for your contribution! Please provide a detailed description
below and ensure you've met all the requirements.
Squashed commit messages must follow the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) standard to
facilitate changelog generation.
Please ensure your PR title follows the Conventional Commits
specification, using the appropriate type (e.g., feat, fix, docs) and
scope.
Examples of good PR titles:
- 💥feat!: change implementation in an non-backward compatible way
- ✨feat(auth): add support for OAuth2 login
- 🐞fix(router): add support for custom metrics
- 📚docs(README): update installation instructions
- 🧹chore(deps): bump dependencies to latest versions
-->
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- Refactor
- Reworked SSE subscription handling to process events synchronously and
centralize error and completion propagation for more deterministic
behavior.
- Bug Fixes
- Reduced race conditions and flaky behavior in subscription flows via
stronger synchronization and guarded state transitions.
- Tests
- Added event-driven test helpers and updated tests to assert per-event
updates, completion, and closure with timeout-based coordination for
more reliable coverage.
- Documentation
- Added notes clarifying test lifecycle and deprecation guidance for
older test utilities.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Checklist
- [ ] I have discussed my proposed changes in an issue and have received
approval to proceed.
- [ ] I have followed the coding standards of the project.
- [ ] Tests or benchmarks have been added or updated.
<!--
Please add any additional information or context regarding your changes
here.
-->
#### Bug
Complete events from SSE subgraph subscriptions were not triggering the
updater correctly, this lead to hanged subscriptions because complete
was not causing client disconnects. Our test suite had poor coverage for
this behaviour.
#### Fix
- Simplified the SSE datasource (by-product of debugging, and it would
have been more complex and less clear what was happening and why if it
was "hotfixed")
- Correctly trigger updater complete when the complete event is sent
from the subgraph
- Complete events trigger closure, and for every other case we have a
deferred close.
- No more leaking goroutines or stuck connections
#### Other
- Made a new testing subscription updater to make writing the tests
easier and fix some existing flawed checks that could result in a
timeout or flaky failure in the future.
---------
Co-authored-by: Alessandro Pagnin <ale@wundergraph.com>1 parent 62d72b2 commit 18c39e7
File tree
3 files changed
+185
-95
lines changed- v2/pkg/engine/datasource/graphql_datasource
3 files changed
+185
-95
lines changedLines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8262 | 8262 | | |
8263 | 8263 | | |
8264 | 8264 | | |
| 8265 | + | |
| 8266 | + | |
| 8267 | + | |
| 8268 | + | |
| 8269 | + | |
| 8270 | + | |
| 8271 | + | |
| 8272 | + | |
| 8273 | + | |
| 8274 | + | |
| 8275 | + | |
| 8276 | + | |
| 8277 | + | |
| 8278 | + | |
| 8279 | + | |
| 8280 | + | |
| 8281 | + | |
| 8282 | + | |
| 8283 | + | |
| 8284 | + | |
| 8285 | + | |
| 8286 | + | |
| 8287 | + | |
| 8288 | + | |
| 8289 | + | |
| 8290 | + | |
| 8291 | + | |
| 8292 | + | |
| 8293 | + | |
| 8294 | + | |
| 8295 | + | |
| 8296 | + | |
| 8297 | + | |
| 8298 | + | |
| 8299 | + | |
| 8300 | + | |
| 8301 | + | |
| 8302 | + | |
| 8303 | + | |
| 8304 | + | |
| 8305 | + | |
| 8306 | + | |
| 8307 | + | |
| 8308 | + | |
| 8309 | + | |
| 8310 | + | |
| 8311 | + | |
| 8312 | + | |
| 8313 | + | |
| 8314 | + | |
| 8315 | + | |
| 8316 | + | |
| 8317 | + | |
| 8318 | + | |
| 8319 | + | |
| 8320 | + | |
| 8321 | + | |
| 8322 | + | |
| 8323 | + | |
| 8324 | + | |
| 8325 | + | |
| 8326 | + | |
| 8327 | + | |
| 8328 | + | |
| 8329 | + | |
| 8330 | + | |
| 8331 | + | |
| 8332 | + | |
| 8333 | + | |
| 8334 | + | |
| 8335 | + | |
| 8336 | + | |
| 8337 | + | |
| 8338 | + | |
8265 | 8339 | | |
8266 | 8340 | | |
8267 | 8341 | | |
| |||
8270 | 8344 | | |
8271 | 8345 | | |
8272 | 8346 | | |
| 8347 | + | |
| 8348 | + | |
8273 | 8349 | | |
8274 | 8350 | | |
8275 | 8351 | | |
| |||
8289 | 8365 | | |
8290 | 8366 | | |
8291 | 8367 | | |
| 8368 | + | |
| 8369 | + | |
8292 | 8370 | | |
8293 | 8371 | | |
8294 | 8372 | | |
| |||
Lines changed: 11 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 47 | + | |
56 | 48 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | 49 | | |
74 | 50 | | |
75 | 51 | | |
| |||
83 | 59 | | |
84 | 60 | | |
85 | 61 | | |
| 62 | + | |
86 | 63 | | |
87 | 64 | | |
88 | 65 | | |
| |||
105 | 82 | | |
106 | 83 | | |
107 | 84 | | |
108 | | - | |
109 | | - | |
| 85 | + | |
110 | 86 | | |
111 | 87 | | |
112 | 88 | | |
| |||
131 | 107 | | |
132 | 108 | | |
133 | 109 | | |
134 | | - | |
| 110 | + | |
135 | 111 | | |
136 | 112 | | |
137 | 113 | | |
138 | 114 | | |
139 | 115 | | |
| 116 | + | |
140 | 117 | | |
141 | 118 | | |
142 | 119 | | |
| |||
165 | 142 | | |
166 | 143 | | |
167 | 144 | | |
168 | | - | |
169 | | - | |
| 145 | + | |
170 | 146 | | |
171 | 147 | | |
172 | | - | |
| 148 | + | |
173 | 149 | | |
174 | 150 | | |
175 | 151 | | |
176 | 152 | | |
177 | 153 | | |
178 | 154 | | |
179 | | - | |
180 | | - | |
| 155 | + | |
181 | 156 | | |
182 | 157 | | |
183 | | - | |
| 158 | + | |
184 | 159 | | |
185 | 160 | | |
186 | 161 | | |
187 | 162 | | |
188 | | - | |
| 163 | + | |
189 | 164 | | |
190 | 165 | | |
191 | 166 | | |
192 | 167 | | |
193 | 168 | | |
194 | | - | |
| 169 | + | |
195 | 170 | | |
196 | 171 | | |
197 | 172 | | |
| |||
210 | 185 | | |
211 | 186 | | |
212 | 187 | | |
213 | | - | |
214 | 188 | | |
215 | 189 | | |
216 | 190 | | |
| |||
0 commit comments