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

Task does not recompute in prod builds when passed into a computed macro (alias, oneWay, readOnly, etc.) #273

Closed
jasonmit opened this issue Jan 28, 2019 · 1 comment

Comments

@jasonmit
Copy link

jasonmit commented Jan 28, 2019

In ember-concurrency >=0.8.24 it seems lastSuccessful, bound within a computed macro, does not compute if another computed is referencing the task as a dependent key and only in production builds. This bug is present only in ember-source@>=3.5.0.

Quite the bug and I plan to bisect soon now that I've duplicated in an example app.

It's worth noting, this code works fine in 0.8.22.

Reproduction:

  • git clone git@github.com:jasonmit/ember-concurrency.git
  • ember s -e=production
  • Browser should open to http://localhost:4200/docs/examples/autocomplete
  • Search anything, notice nothing renders.
  • Open tests/dummy/app/docs/examples/autocomplete/controller.js and uncomment line 12-14 and comment out line 9 and Save
  • Search again
  • Notice bug is no longer present
<input type="text" oninput={{perform searchRepo value="target.value"}} />
<div>Has Results:</div>
<div>{{hasResults}}</div>
<div>Results (bug - nothing will appear):</div>
<ul>
  {{#each lastSuccessful as |repo|}}
    <li>{{repo.full_name}}</li>
  {{/each}}
</ul>
export default Controller.extend({
  lastSuccessful: readOnly('searchRepo.lastSuccessful.value'),

  // Uncomment this block and bug will not be present
  // lastSuccessful: computed('searchRepo.lastSuccessful.value', function() {
  //   return this.get('searchRepo.lastSuccessful.value');
  // }).readOnly(),

  hasResults: computed('lastSuccessful', 'searchRepo.isRunning', function() {
    // accessing a prop triggers the bug (happens with isIdle as well)
    this.searchRepo.isRunning;

    return this.get('lastSuccessful.length') > 0;
  }),

  searchRepo: task(function * (term) {
    if (isBlank(term)) { return []; }

    let res = yield fetch(`https://api.github.com/search/repositories?q=${term}`);
    let json = yield res.json();

    return json.items.slice(0, 10);
  })
});
@jasonmit jasonmit changed the title lastSuccessful does not recompute in prod builds lastSuccessful does not recompute in prod builds when used with computed macros Jan 29, 2019
@jasonmit jasonmit changed the title lastSuccessful does not recompute in prod builds when used with computed macros Task does not recompute in prod builds when used with computed macros Jan 29, 2019
@jasonmit jasonmit changed the title Task does not recompute in prod builds when used with computed macros Task does not recompute in prod builds when passed into a computed macro (alias, oneWay, readOnly, etc.) Jan 29, 2019
jasonmit added a commit to jasonmit/ember-concurrency that referenced this issue Jan 29, 2019
@jasonmit jasonmit reopened this Jan 29, 2019
jasonmit added a commit to jasonmit/ember-concurrency that referenced this issue Jan 29, 2019
@jasonmit
Copy link
Author

After triaging further, it looks like emberjs/ember.js#17487 will resolve the issue.

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

No branches or pull requests

1 participant