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

This is a known limitation of js. I hate this limitation.

```
function fit () {
  ....
  // Somewhere in depth.
  function ololo() {
    console.log('ololo');
    setTimeout(ololo, 1000);
  }
  ololo();
  ...
}
var _fit = new fit();

setTimeout(function () {
  // Our single CPU is here.
  // Listen, I don't want you to go into _fit anymore!
  // Please remove all points that you've made in CPU scheduler for _fit call.
  // _fit.kill();
  // process.cpu_scheduler.remove_all_points_created_from(_fit);
  // process.cpu_scheduler.points.forEach(function (point) {
  //   if (point.stack.some(function (parent) {
  //     return parent === _fit;
  //   }) {
  //     point.remove();
  //   }
  // });
  // myCustomCPUSchedulerForFit.points.forEach(function (point) {
  //   point.remove();
  // });
  // myCustomCPUSchedulerForFit.destroy();
}, 2000);
```

It is not possible. Why? Because js is not designed properly. You couldn't manage CPU scheduler. You couldn't force CPU scheduler to store full stack trace for each point. You couldn't provide a custom CPU scheduler.

What is a solution?
```
function fit () {
  var self = this;
  ...
  if (!self.ifAborted) {
    ...
}
var _fit = new fit();
setTimeout(function () {
  _fit.ifAborted = true;
  ...
}, 2000);
```

`ifAborted` means that `_fit` call is dead. But our single CPU will dive into our dead scope again and again. We will receive performance and business logic issues just because we couldn't kill the dead scope.

You can see millions of such bool guards in any javascript project. Javascript is just a toy. You shouldn't use it for any reliable solutions.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/27#issuecomment-252993759

Received on Tuesday, 11 October 2016 17:55:35 UTC