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

> exit does not reject so await is not meaningful anymore the way it is with cancellation, right?

It should work with await like this:

```javascript
async function doReq() {
  var req = ajax(...);

  setTimeout(function() {
    req.end();
    // here if req was settled at this moment this will have not effect and
    // console.log will be executed, but if not, then |end()| will lock |req| promise
    // and all pending consumers since they are doing nothing
    // after that call of |doSomething| will be GCed
  }, 100);

  return req;
}

async function  doSomething() {
  var response = await doReq();
  console.log('got response', response);
}

doSomething();
```

> but it's not clear what would happen if no symbol is provided what an .end() call should do in case of Promise.resolve(42).end()

I believe ```Promise``` (next version of promise, all in my mind of course) should have default action for ```Symbol.lock```. In case of ```Promise.resolve(42).end()``` it should be simply GC operation for 42 and locking that promise (all methods becomes no-op, so .then() will return other locked promise, or some sort of stub).

Anyway, I understand what my proposal is not ideal since it's made in a few hours and I have no more free time for it yet. But I am happy to answer question if it might help.


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

Received on Tuesday, 31 March 2015 20:21:39 UTC