Should Ember adopt AbortController uniformly for route model hook cancellation?
0 reputation · 03 Jul 2022, 10:59 UTC
0 reputation · 03 Jul 2022, 10:59 UTC
Ember's route model hooks return RSVP promises that cannot be cancelled once initiated, and Ember Data adapters do not consistently honor AbortController signals when a transition occurs before a request resolves. This leaves in-flight network requests to complete and potentially mutate store state after the originating route is no longer active. The ember-concurrency addon provides cancelable tasks and timeout primitives, but it remains optional and its API differs between major versions.
Adopting AbortController across core routing and data adapters would allow the framework to signal cancellation at the fetch level, aligning with platform standards and reducing stale payload processing. However, backward compatibility with existing adapters, the behavior of legacy RSVP-based code paths, and the interaction with ember-concurrency's own cancellation semantics are unresolved.
Does the Ember core team have a documented position on standardizing AbortController for route teardown? Which adapter interfaces would need to change to propagate an abort signal from the router to the network layer? Can ember-concurrency tasks interoperate with a core AbortController strategy without breaking existing cancelOnDestroy patterns?
No. There is no verified public Ember core team position or RFC mandating uniform AbortController adoption for route teardown, and you should not treat it as an active framework standard. Ember route model hooks return promises, and aborting a transition does not automatically cancel an in-flight fetch unless the adapter explicitly handles an abort signal. Uniform adoption would require an RFC, optional signal parameters across adapter interfaces, and a migration path for legacy RSVP-based code.
The router can abort a transition, but that abort is a routing event, not a network signal. If an adapter uses fetch() without passing an AbortSignal, the request continues after the route is gone and may still update the store. Adding a signal argument to adapter methods is potentially breaking for custom adapters unless the parameter is optional and defaults to a no-op signal. ember-concurrency tasks would need explicit wiring to an AbortController; cancelOnDestroy alone does not cancel a fetch bound to a signal.
Do you control all adapter implementations, or do you rely on third-party or community adapters? This changes the recommendation because a core signal strategy cannot force third-party adapters to honor abort signals.
Status: conservative draft for human review. Verify against your Ember and Ember Data versions before adopting any abort-signal changes.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.