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

fix(task): eventTask/Periodical task should not be reset after being cancelled when running#642

Merged
mhevery merged 1 commit intoangular:masterfrom
JiaLiPassion:canceltask
Mar 7, 2017
Merged

fix(task): eventTask/Periodical task should not be reset after being cancelled when running#642
mhevery merged 1 commit intoangular:masterfrom
JiaLiPassion:canceltask

Conversation

@JiaLiPassion
Copy link
Copy Markdown
Collaborator

the issue can be described as the following cases.

     const zone = Zone.current.fork({name: 'testZone'});

     const task = zone.scheduleMacroTask('testPeriodTask', () => {
       zone.cancelTask(task);
     }, {isPeriodic: true}, () => {}, () => {});

    task.invoke();
    expect(task.state).toBe('notScheduled');

    
     const task = zone.scheduleEventTask('testEventTask', () => {
       zone.cancelTask(task);
     }, null, () => {}, () => {});

    task.invoke();
    expect(task.state).toBe('notScheduled');

When task is cancelled in task's callback(running state), the runTask logic here https://github.com/angular/zone.js/blob/master/lib/zone.ts#L757 will reset the task's state to scheduled, so it will cause issues such as #638, updateTaskCount cause null error, because the task is cancelled but still in scheduled state.

@naveedahmed1
Copy link
Copy Markdown

naveedahmed1 commented Mar 2, 2017

Can this be released anytime soon? Because it breaks Angular applications in most of the cases.

@naveedahmed1
Copy link
Copy Markdown

Thank you so much @mhevery my Angular 2 app is stable again after this update :)

@JiaLiPassion JiaLiPassion deleted the canceltask branch March 17, 2017 03:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants