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

Max stack call error in prod mode with asserts (v5, v4) #8710

Closed
lifeart opened this issue Jul 13, 2023 · 3 comments
Closed

Max stack call error in prod mode with asserts (v5, v4) #8710

lifeart opened this issue Jul 13, 2023 · 3 comments

Comments

@lifeart
Copy link

lifeart commented Jul 13, 2023

At the moment, if debug data is not stripped from prod build, we have recursion error.

Given: Prod build, assert function is not stripped.

  1. Trying to access any key (id, for example) on just created model.

  2. This code part is executed:

    return peekCache(this).getAttr(recordIdentifierFor(this), key);

  3. And here we calling toString on record:

    assert(`${String(record)} is not a record instantiated by @ember-data/store`, RecordCache.has(record));

  4. And we going here:

    return `<model::${this.constructor.modelName}:${this.id}>`;

Where we access this.id and here is GOTO: 1.

@lifeart
Copy link
Author

lifeart commented Jul 13, 2023

It's not an real issue, but may appear on non ember-cli/embroider envs.

In codebase we have quite alot of cases, referring to model id.
One of possible workarounds - try to prevent nested toString calls on model.

{
  #isToStringInProgress = false;
  toString() {
    if (this.#isToStringInProgress) {
      return `<${this.constructor.modelName}:unknown>`;
    }
    this.#isToStringInProgress = true;
    try {
      return  `<model::${this.constructor.modelName}:${this.id}>`; 
    } finally {
      this.#isToStringInProgress = false;
    }
  }
}

@runspired
Copy link
Contributor

this is why non ember-cli/embroider envs still need a build config (and build plugin). Not running our final build step will produce a very un-tested and dramatically different library with significantly degraded performance characteristics

@runspired
Copy link
Contributor

Closing as nothing for us to do here on this ticket, tracking for broader compat is in #8147 and for embroider/vite is in #8103

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

No branches or pull requests

2 participants