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

Maximum call stack size exceeded error when accessing relationship #502

Closed
miguelcobain opened this issue Jun 7, 2020 · 9 comments
Closed

Comments

@miguelcobain
Copy link
Contributor

miguelcobain commented Jun 7, 2020

When I try to access a property of a belongs to relationship of a changeset object, I get a Maximum call stack size exceeded error. The error comes out wether you use the changeset-get helper or not.

Example:

{{this.changeset.belongsToRelationship.name}}

or

{{changeset-get this.changeset "belongsToRelationship.name"}}

The changeset object was created using

this.set('changeset', new Changeset(this.model));

Here's what the error looks like:
Screen Shot 2020-06-07 at 04 11 11

From what I was able to understand, I'm getting into an infinite loop around the safeGet here on the validated-changeset package: https://github.com/validated-changeset/validated-changeset/blob/e1dd9a65d19fd1e269b48049855421d32a041cfd/src/utils/object-tree-node.ts#L49

The key that it loops in is __CUSTOM_TAG_FOR__ember159149944767897589162650__.

I tried to PR a failing test, but it seemed like relationships are pretty will tested in ember-changeset, so I'm a bit lost now. :(

I'm using version 3.5.5, but this also happened with every other 3.X version.

Using ember and ember data 3.18.

@snewcomer
Copy link
Collaborator

👋 Thanks for the issue. I originally had a check to make sure it was not inherited. Looks like that property is not inherited so the fix below wouldn't have worked (as you indicated).

adopted-ember-addons/validated-changeset@1240507

At first glance, I am a little lost. Pushed up a failing test for now...

@snewcomer
Copy link
Collaborator

This seems like a less than ideal work-around but I wonder if we cache (WeakMap for the ObjectTreeNode instance) the "gotten" keys for content only (content is assumed frozen until we execute the underlying changes)

@miguelcobain
Copy link
Contributor Author

@snewcomer I'm really not familiar with validated-changeset or ember-changeset internals, so I can't really talk about the validity of your workaround suggestion. :)
But it would be really good to have a workaround in userland for everyone that ends up in here.

@snewcomer
Copy link
Collaborator

closed with v3.5.6 and changeset-get!

@miguelcobain
Copy link
Contributor Author

@snewcomer could it be possible that this error is still happening when the belongsTo relationship is null?

@miguelcobain
Copy link
Contributor Author

@snewcomer I was able to reproduce this in a failing test this time: #504

@snewcomer
Copy link
Collaborator

Probably. We effectively need to something like this PR so we don't go down the deep deep hole of trying to iterate ember-data objects

adopted-ember-addons/validated-changeset#67

@snewcomer
Copy link
Collaborator

3.5.7!

@miguelcobain
Copy link
Contributor Author

I can confirm that it is working now. Thanks a lot @snewcomer !

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

2 participants