Skip to content
This repository has been 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
merged 1 commit into from
Mar 7, 2017

Conversation

JiaLiPassion
Copy link
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

naveedahmed1 commented Mar 2, 2017

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

@naveedahmed1
Copy link

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