Commit c6ce71d
feat(schema-renderer): abort in-flight findAll on cleanup and re-run
SchemaRenderer's `createQuerySignal` and `$single` paths both run
`ModelClass.findAll` inside a `createEffect`. The effect re-runs on any
reactive dependency change (perspective swap, params token update) and
the component can unmount mid-query. Without cancellation the stale
findAll keeps grinding through SPARQL serialisation, network round-trip,
and client-side deserialisation — work that's discarded the moment a
fresher result arrives.
Wires an `AbortController` scoped to each effect iteration:
- `onCleanup` aborts the controller before the effect re-runs or the
component unmounts.
- The `findAll(p, queryOptions, { signal })` call forwards the signal
to ad4m's `Ad4mModel.findAll` (extended in
coasys/ad4m#855 to thread the signal through
`modelQuery` → `apiClient.call` → the executor's `request.cancel`
WebSocket message).
- `.then` guards on `controller.signal.aborted` to ignore the stale
result if the controller fired before the promise resolved.
- `.catch` swallows `DOMException('Aborted', 'AbortError')` so
cancellation isn't surfaced to the UI as an error — the new effect
run (or unmount) handles state instead.
The subscribe path already cleans up via `builder.dispose()` and isn't
changed.
Caveat: the executor's Oxigraph SPARQL engine can't be interrupted
mid-evaluation; what's saved is the JSON serialise + WebSocket reply +
client deserialise tax, which dominates for any non-trivial result set.
Tests (queryToken.test.tsx):
- findAll receives an AbortSignal in `options.signal`.
- Unmount aborts the controller.
- Re-running the effect (perspective signal change) aborts the prior
controller and gives the new run a fresh, un-aborted signal.
- AbortError rejection is swallowed without surfacing.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent deb4c5b commit c6ce71d
2 files changed
Lines changed: 130 additions & 4 deletions
Lines changed: 38 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
238 | | - | |
239 | | - | |
240 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
241 | 261 | | |
242 | 262 | | |
243 | 263 | | |
| |||
557 | 577 | | |
558 | 578 | | |
559 | 579 | | |
560 | | - | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
561 | 595 | | |
562 | 596 | | |
563 | 597 | | |
| |||
Lines changed: 92 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
231 | 323 | | |
232 | 324 | | |
233 | 325 | | |
| |||
0 commit comments