Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

ZoneTask.toString() method missing #341

Closed
char0n opened this issue May 1, 2016 · 6 comments
Closed

ZoneTask.toString() method missing #341

char0n opened this issue May 1, 2016 · 6 comments

Comments

@char0n
Copy link

char0n commented May 1, 2016

I have reported this issue to AngularJs team: angular/angular.js#14548

Basically their are right in their assumption that using zone.js should not change setTimeout. Imagine this situation when using zone.js.

var deferredTracker = {}

var timerId1 = setTimeout(function() {});
var timerId2 = setTimeout(function() {});

deferredTracker[timerId1] = new Promise(....);
defferedTracker[timerId2] = new Promise(....);

The result of defferedTracker is:

{"[object Object]": promiseInstance}

This is the way angular1 tracks timeouts and interval. Using zone.js allows to cancel only the last timeout or interval.

To fix this issue I would suggest for ZoneTask to have toString method which for setTimeout and setInterval should look like this:

toString: function() {
  return this.data.handleId;
} 

Without fixing this, using zone.js in angular1 application is just not possible.

Thank you

@char0n
Copy link
Author

char0n commented May 17, 2016

I have created modified distribution file here: http://filebin.ca/2hRxo13INo5U/zone.js-0.6.12.tgz

Affected files are:

  • dist/zone.js
  • dist/zone-node.js

Both files have toString method implemented. Using this file is the only way to use zone.js along with angular 1.5 side by side.

@mhevery
Copy link
Contributor

mhevery commented May 17, 2016

@char0n Nice catch. Could you create PR with a fix?

@char0n
Copy link
Author

char0n commented May 18, 2016

@mhevery I'll try

@char0n
Copy link
Author

char0n commented May 18, 2016

I am having problem installing the project. I run on Windows 8.1. In order to install the project I had to modify the package.json:

"prepublish": "./node_modules/.bin/typings install && ./node_modules/.bin/tsc && gulp build"

to

"prepublish": "./node_modules/.bin/typings install && call ./node_modules/.bin/tsc && gulp build"

Then when I run npm install I get this error:

> zone.js@0.6.12 prepublish C:\Users\char0n\Documents\GitHub\zone.js
> typings install && call ./node_modules/.bin/tsc && gulp build


├── es6-promise (ambient)
├── node (ambient)
└── jasmine (ambient dev)

[10:30:27] Using gulpfile ~\Documents\GitHub\zone.js\gulpfile.js
[10:30:27] Starting 'build/zone.js'...
[10:30:28] Starting 'compile'...
[10:30:28] Starting 'build/zone.min.js'...
[10:30:28] Starting 'build/zone-node.js'...
[10:30:28] Starting 'build/jasmine-patch.js'...
[10:30:28] Starting 'build/jasmine-patch.min.js'...
[10:30:28] Starting 'build/long-stack-trace-zone.js'...
[10:30:28] Starting 'build/long-stack-trace-zone.min.js'...
[10:30:28] Starting 'build/wtf.js'...
[10:30:28] Starting 'build/wtf.min.js'...
[10:30:28] Starting 'build/async-test.js'...
[10:30:28] Starting 'build/fake-async-test.js'...
[10:30:28] Starting 'build/sync-test.js'...
events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: spawn ./node_modules/.bin/tsc ENOENT
    at exports._errnoException (util.js:856:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at _combinedTickCallback (node.js:377:13)
    at process._tickCallback (node.js:401:11)
    at Function.Module.runMain (module.js:449:11)
    at startup (node.js:141:18)
    at node.js:933:3

npm verb lifecycle zone.js@0.6.12~prepublish: unsafe-perm in lifecycle true
npm verb lifecycle zone.js@0.6.12~prepublish: 

Here is full npm-debug.log: https://gist.github.com/char0n/ac5d88b2067f715d4320998292d1de32
node version: 5.7.0
npm version: 3.6.0

@hmdhk
Copy link
Contributor

hmdhk commented May 18, 2016

Is there a way to keep the native behaviour of setTimeout, i.e. returning a numerical ID of the timeout?

@chuanqisun
Copy link

after updating to rc.3, I can't repro #361 anymore.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants