Re: [fetch] Aborting a fetch (#27)

> If someone changes the code at a distance to behave differently of course you get action-at-a-distance.

Assume that `foo` and `cancellableFunction` have nothing in common, except that they both use promises. `foo`'s contract with the client is to return something unrelated at some point in the future. `cancellableFunction` on the other hand does something visible, like painting on the screen or blinking lights, that the user cares about, and cares about whether it is happening or not.

The client does not care exactly how `foo` is implemented - and shouldn't have to - and is therefore surprised when `cancellableFunction` does not stop blinking, and surprised again when it starts working later. [*It is very difficult, however, to track down which component is responsible*](https://en.wikipedia.org/wiki/Action_at_a_distance_%28computer_programming%29). Is it because the client skipped calling foo, or updated to a newer version of `foo`? The only way to find out is trial and error!

Blaming the implementation of `foo` is low. `foo` could care less about cancellation and does not know or care about `cancellableAction`. When `foo` takes the *innocent action* of changing whether to internally sequence multiple calls on itself - something that appreciably should have no effect whatsoever on clients whose calls don't overlap, which is the case here - then clients are suddenly affected in an unintended and surprising way. The [*behavior in one part of a program varies wildly based on difficult or impossible to identify operations in another part of the program*](https://en.wikipedia.org/wiki/Action_at_a_distance_%28computer_programming%29).

Worse, you still haven't told me how `foo` can fix this so it doesn't interfere with cancellation.

> The point is that the semantics of your code don't change, the same paths still get executed regardless of how the code was changed at foo

The client intended for `p.cancel()` to cancel `cancellableFunction`. When defined semantics don't match client intent, then the semantics suck.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/27#issuecomment-179111950

Received on Wednesday, 3 February 2016 09:15:46 UTC