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

Service cannot be used before helper #1085

Open
MichalBryxi opened this issue Sep 25, 2024 · 0 comments
Open

Service cannot be used before helper #1085

MichalBryxi opened this issue Sep 25, 2024 · 0 comments

Comments

@MichalBryxi
Copy link
Contributor

MichalBryxi commented Sep 25, 2024

The problem

Given code:

import Component from '@glimmer/component';
import fileQueue from 'ember-file-upload/helpers/file-queue';

export default class Foo extends Component {
      @service fileQueue;

      <template>
       {{! Block A }}
        <ul>
          {{#each this.fileQueue.files as |file|}}
            <li>
              {{file.name}}
            </li>
          {{/each}}
        </ul>
        
        {{! Block B }}
        {{#let (fileQueue) as |queue|}}
          <label>
            <input type='file' {{queue.selectFile}} hidden />
            Select File
          </label>
        {{/let}}
      </template>
}

The app will fail with:

ember.js:626 Uncaught (in promise) Error: Assertion Failed: You attempted to update `_value` on `TrackedStorageImpl`, but it had already been used previously in the same computation.  Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.

`_value` was first used:

- While rendering:
  -top-level
    application
      index
        (unknown template-only component)
          (result of a `unknown` helper)
            (result of a `unknown` helper)
              (result of a `unknown` helper)
                false.files
  • Curiously enough, if the Block A and Block B are swapped, the app works just fine

Versions

  • "ember-file-upload": "^9.1.0",
ember --version
ember-cli: 5.4.1
node: 20.17.0
os: darwin x64

pnpm --version
9.9.0
MichalBryxi added a commit to MichalBryxi/ember-file-upload that referenced this issue Sep 25, 2024
- When `fileQueue` service is used _before_ `(fileQueue)` helper, then app fails with:

```
ember.js:626 Uncaught (in promise) Error: Assertion Failed: You attempted to update `_value` on `TrackedStorageImpl`, but it had already been used previously in the same computation.  Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.

`_value` was first used:

- While rendering:
  -top-level
    application
      index
        (unknown template-only component)
          (result of a `unknown` helper)
            (result of a `unknown` helper)
              (result of a `unknown` helper)
                false.files
```
- This PR is just to document the issue described in adopted-ember-addons#1085
MichalBryxi added a commit to MichalBryxi/ember-file-upload that referenced this issue Sep 25, 2024
- When `fileQueue` service is used _before_ `(fileQueue)` helper, then app fails with:

```
ember.js:626 Uncaught (in promise) Error: Assertion Failed: You attempted to update `_value` on `TrackedStorageImpl`, but it had already been used previously in the same computation.  Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.

`_value` was first used:

- While rendering:
  -top-level
    application
      index
        (unknown template-only component)
          (result of a `unknown` helper)
            (result of a `unknown` helper)
              (result of a `unknown` helper)
                false.files
```
- This PR is just to document the issue described in adopted-ember-addons#1085
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