Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rule: no-timeout-in-infinite-loop #4

Open
Turbo87 opened this issue Apr 17, 2020 · 1 comment
Open

New Rule: no-timeout-in-infinite-loop #4

Turbo87 opened this issue Apr 17, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@Turbo87
Copy link
Collaborator

Turbo87 commented Apr 17, 2020

http://ember-concurrency.com/docs/testing-debugging describes the problem quite well. These days we have access to rawTimeout() though, which can often solve the issue of the infinitely waiting test waiters.

Bad

pollForChanges: task(function * () {
  while (true) {
    yield pollServerForChanges();
    yield timeout(5000);
  }
})

Good

pollForChanges: task(function * () {
  while (true) {
    yield pollServerForChanges();
    yield rawTimeout(5000);
  }
})
pollForChanges: task(function * () {
  while (!Ember.testing) {
    yield pollServerForChanges();
    yield timeout(5000);
  }
})
@Turbo87 Turbo87 added the enhancement New feature or request label Apr 17, 2020
@sdahlbac
Copy link

I'll have a go at this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants