Skip to content

Is bug? is bugfix? :: affecting ember-source 5.6+ with false-negatives w/ backtracking re-render assertions #1629

Open
@NullVoxPopuli

Description

@NullVoxPopuli

Reproduction in Limber (locally running on port 4301)

Notes:


Examples of real code that "broke" in ember 5.6+ (which, imo, is legit problematic, and should be migrated away from)

  • creating records in class properties
    @tracked createdModel = this.store.createRecord('model-name');
    this is problematic because createRecord interacts with "Live arrays", which have previously been used on the pages (imagine a table view with a navigatable create modal).
    • What should happen instead: folks should only call createRecord as the result of a user action, such as submitting a form.
  • Setting data outside of the current context / component as a result of construction
    constructor(owner, args) {
      super(owner, args);
      
      if (this.args.options.length === 1) {
        this.setType(this.args.options[0]);
      }
    }
    
    selectedRelatedData = this.args.relatedData;
    
    setType = (option) => {
      // option is tracked
      this.selectedRelatedData.option = option;
    }
    • What should happen instead: is that selectedRelatedData should be derived, as should the type, potentially using localCopy from tracked-toolbox if local state forking needing.
      for example:
      get _type() {
        if (this.args.options.length === 1) {
          return this.args.options[0];
        }
      }
      
      @localCopy('_type') type;
  • making requests on reactive data in the constructor
    constructor() {
      super(...arguments);
      this.setup();
    }
    
    setup = () => {
      this.args.model.data?.reload();
    }
    This has the same problem as above, where the data can be a part of a live array (or other structure) elsewhere on the page.
    • What to do instead: fetch data earlier (such as in the model hook), or wait to fetch until a user interaction.
  • Changing the route upon construction of a component
    constructor() {
      super(...arguments);
      
      this.router.transitionTo(`route.name.here`);
    }
    • What to do instead: either don't even have this component in the first place, or have whatever is wanting to render this component just do the transition instead (for example, as the result of a user interaction)

Examples of real code that "broke" in ember 5.6+ which maybe shouldn't have

... trying to find reproductions ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions