ember-inspector
ember-inspector copied to clipboard
The inspector seems to influence Ember Data record creation
Describe the bug
We have a route that creates certain records when they don't exist yet. We assign them default values on creation by passing data into the createRecord
method. For example;
store.createRecord('model-name', {
someAttribute: 'Hello',
});
I noticed that sometimes the initial values aren't set correctly and I couldn't figure out why. Eventually I realized it's caused by having the inspector open when the page loads. If I close the dev tools, reload, open the data tab and look at the values, everything works. If I do the same without first closing the dev tools, the values aren't set. What's even more strange is that it only seems to happen for the first record that's created this way. The second one does have the values we pass into it.
It's also not just a visual bug, the value hasn't actually been stored in the record so record.someAttribute
will return undefined.
Another thing I noticed is that first creating the record before setting the value doesn't have the same issue:
let record = store.createRecord('model-name');
record.someAttribute = 'hello';
That will always work, no matter if the dev tools are open when reloading. If you then create a second record with the initial value object, that still works as expected which makes me think it might be a timing issue?
I'll try to create a reproduction to see if it's related to our setup or not.
To Reproduce Steps to reproduce the behavior:
- Create new records with initial values
- Reload the page with the dev tools activated
- Go to the data tab and verify that not all default values have been set.
Expected behavior The dev tools do not affect application code.
Screenshots
Reloading the page with the dev tools closed:
Reloading the page with the dev tools open ("Primary" is missing)
Environment Ember version, browser, etc. Ember 3.26, Firefox 96
Additional context Add any other context about the problem here.
May be related to: https://github.com/emberjs/ember-inspector/issues/1875
the fixes for #1875 should also fix this
Just had the issue with:
- Ember Inspector 4.9.1
- "ember-data": "~3.27.1"
This bug should be re-opened 🤷♂️
I think you need at least ember data 3.28, which includes the fix