data icon indicating copy to clipboard operation
data copied to clipboard

4.13 Canary | Regression Tracking

Open runspired opened this issue 1 year ago • 20 comments

WONTFIX

  • transforms now come from a public instead of private import location
  • setConfig is required if not using the ember-data package
  • extending @ember-data/store instead of ember-data/store now requires full configuration
  • super in hooks in classes extending @ember-data/store no longer works
  • model._notifyProperties has been removed
  • cache is stricter:
    • You must include an 'id' for the resource data ${resource.type}
    • Missing Resource Type: received resource data with a type '${resource.type}' but no schema could be found with that name.
  • mutating an attribute on a record by setting it directly will now generate a change notification for that attribute. Previously, because attr is implemented as a computed prop we were relying on it managing its own value and not emitting the notification. This caused bugs for other consumers of the change (inspector, references, schema-record) and so we no longer swallow this notification.
    • this can have the unexpected effect of causing tracked functions and cached getters which create new records to recompute if the attribute which is mutated was originally set inside the tracked function or cached getter, as it will be subscribed to this change.
  • Backports fix for https://github.com/emberjs/data/issues/9053
  • the private APIs belongsToReference.belongsToRelationship and hasManyReference.hasManyRelationship have been removed.
  • There appears to be a subtle timing change around notifying the identity and state of a new record as it is saved.
  • we now subscribe to notifications for requests in the Request component, this can lead to some re-renders that wouldn't have occurred before when cache updates.
  • we no longer notify attribute keys that aren't in the schema

MAYBEFIX

  • adapter.useFetch is assigned in a new way, resulting in the getter approach in app adapters not working. fields approach works e.g. useFetch = false.

  • isRelationship and isAttribute on field meta is no longer present. These were meant to be private and not part of the spec, but some apps may have discovered and made use of them.

  • key on field meta is no longer present, this was a private reflection of name and name should be used instead.

  • relationship graph uses the passed in arrays from operations that update remote state for perf, this exposes them to accidental mutation later. We should consider freezing and/or slicing these arrays in debug as this is mostly an issue with tests using mirage.

    • This can result in Relationship state sometimes storing non-stable identifiers
  • if you call createRecord in a test expecting a re-render, you need to await settled

  • inverseFor().type is now always a string, before it could be a class https://github.com/emberjs/data/issues/9970

TO FIX

  • deprecated registerSchema does not setup schema in a way that avoids the store attempting to call createSchemaService
  • getSchemaDefinitionService only checks for schemas registered with registerSchema
  • app-re-exports erroneously use build config

FIXED

  • https://github.com/emberjs/data/issues/9611 (affects both 5.x and 4.13)
  • ember-inflector support initializer needs to be backported
  • existing notification bug where we will notify attribute keys that aren't in the schema (e.g. due to the API returning keys that aren't in the schema which is really common in Mirage) can lead to over-notification issues now that we subscribe to these notifications in the Request component. Fixed by no-longer notifying for keys not in the schema. https://github.com/emberjs/data/pull/9698
  • receiving a new request with the same id as the original request in the request component can error because the second request will be backgrounded and we don't account for that in the request validation. Error is The `request` passed to `RequestManager.request(<request>)` was empty (`{}`). Requests need at least one valid key. https://github.com/emberjs/data/pull/9685
  • hasMany relationships will notify any time they receive an updated payload even if the state is exactly the same due to the fix in # for ensuring we notify for potential re-ordering. (https://github.com/emberjs/data/commit/feb6e5a64a744f0ca2dfabf2dab1bf6fbb8ef976#diff-6bf06ca7b029990de472c9fae36ea1e7e074b8e3d8ddfaf87edc2b5eb41e5d76R154)

runspired avatar Jan 16 '25 06:01 runspired

Trying out 4.13-alpha.4 (upgraded from latest 4.12) I ran into what appears to be an inflection issue.

Did anything change in that area, or am I missing something else?

Model definition with @belongsTo('media', { inverse: null, async: true }) media; with a model named media.js now throws Error: No model was found for 'medium' and no schema handles the type at runtime.

It's set up with the inflector as: Inflector.inflector.uncountable('media', 'media');

nickschot avatar Feb 21 '25 14:02 nickschot

@nickschot great find! in 5.x we deprecated support for ember-inflector. 5.x deprecations are activateable in 4.13 but off-by-design since they would be new deprecations.

To manage that deprecation, we automatically intercept inflections from ember-inflector and add them to our own inflection library.

That interception logic in ember-data may not be setup right in 4.13, or you may be assembling the packages yourself (as opposed to using ember-data) in which case the interception needs to be explicitly installed in your app. I'll look into the former.

Sidenote: the check if (macroCondition(dependencySatisfies('ember-inflector', '*'))) { will fail if ember-inflector is not installed by your app as a direct dependency iirc.

runspired avatar Feb 21 '25 17:02 runspired

Some quick answers to that & a bit more context:

  • ember-inflector was already a direct devdep of the app
  • we use ember-data and extend the store from ember-data/store, but I did have to install @ember-data/store and @warp-drive/build-config for it to build/boot. There is a bit of customisation of the store service, but it does call super etc.
  • @embroider/macros is also a direct dep
  • I tried to check if the macroConditions in request-utils/deprecation-support even run, but I don't see them triggered. I noticed in current ember-data that's imported here: https://github.com/emberjs/data/blob/main/packages/-ember-data/app/initializers/ember-data.js#L1 while something like that doesn't appear to be present in 4.13 https://github.com/emberjs/data/blob/v4-main/packages/-ember-data/app/initializers/ember-data.js (I don't know the depth of the other imports there, but it might be a hint).
  • the app doesn't use Embroider, latest auto-import is present.

EDIT:

  • After manually importing deprecation-support in an initializer it seems to work, so looks like it might just be that import missing somewhere.

nickschot avatar Feb 21 '25 18:02 nickschot

Thanks! I'll get that initializer backported :)

runspired avatar Feb 21 '25 20:02 runspired

@nickschot Can you try the latest 4.13 canary? It should have the initializer fix.

gitKrystan avatar Mar 10 '25 23:03 gitKrystan

@nickschot Can you try the latest 4.13 canary? It should have the initializer fix.

Most of our test suite seems to pass on CI, but the initializer fix doesn't seem to work when running tests through localhost:4200/tests.

I also had to make sure to have all the proper @ember-data & @warp-drive packages available in the top level node_modules (did a quick fix with a public hoist for testing).

There's also some other issues, but I have to dig into those more to see if that's just caused by the test setup.

nickschot avatar Mar 11 '25 09:03 nickschot

the initializer fix doesn't seem to work when running tests

via any mechanism or just when launching that way?

available in the top level node_modules

because typescript? or because you build with embroider which disallows the transitive dependency and thus things like import Model from '@ember-data/model'; don't "just work" anymore?

runspired avatar Mar 11 '25 09:03 runspired

the initializer fix doesn't seem to work when running tests

via any mechanism or just when launching that way?

available in the top level node_modules

because typescript? or because you build with embroider which disallows the transitive dependency and thus things like import Model from '@ember-data/model'; don't "just work" anymore?

As discussed in chat: breaks on visiting /tests but works on CI with prebuilt app (environment=test) + ember-exam

In addition @warp-drive/build-config currently needs to be hoisted/added to deps. From chat:

TLDR we need to ensure app re-exports are exported out of library code so that build config is processed correctly

nickschot avatar Mar 11 '25 10:03 nickschot

I just updated from 4.13.0-alpha.4 to 4.13.0-alpha.5, and now I’m getting an error related to Webpack and ember-auto-import. If I remove the setConfig from ember-cli-build and use the legacy emberData key, everything works fine again, though I get a warning to use setConfig.

@warp-drive/build-config is hoisted.

  - name: Error
  - nodeAnnotation: ember-auto-import-webpack
  - nodeName: WebpackBundler
  - originalErrorMessage: webpack returned errors to ember-auto-import
  - stack: Error: webpack returned errors to ember-auto-import

LuisMacedoKantar avatar Mar 12 '25 15:03 LuisMacedoKantar

@LuisMacedoKantar is there a log of what the error is anywhere?

runspired avatar Mar 12 '25 19:03 runspired

Yes @runspired

ERROR Summary:

  • broccoliBuilderErrorStack: Error: webpack returned errors to ember-auto-import at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/webpack.js:541:32 at finalCallback (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:500:32) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:578:17 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/HookWebpackError.js:67:2 at Hook.eval [as callAsync] (eval at create (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/Hook.js:18:14) at Cache.storeBuildDependencies (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Cache.js:126:37) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:574:19 at Hook.eval [as callAsync] (eval at create (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/Hook.js:18:14) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:570:23 at Compiler.emitRecords (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:1046:4) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:560:11 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:1009:14 at Hook.eval [as callAsync] (eval at create (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/Hook.js:18:14) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:1006:27 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:2818:7 at done (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:3522:9) at Hook.eval [as callAsync] (eval at create (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:835:33 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/graceful-fs/graceful-fs.js:143:16 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/graceful-fs/graceful-fs.js:61:14 at FSReqCallback.oncomplete (node:fs:192:23)
  • code: [undefined]
  • codeFrame: webpack returned errors to ember-auto-import
  • errorMessage: webpack returned errors to ember-auto-import at WebpackBundler (ember-auto-import-webpack) -~- created here: -~- at new Plugin (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/broccoli-plugin/dist/index.js:47:36) at new WebpackBundler (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/webpack.js:115:9) at AutoImport.makeBundler (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/auto-import.js:153:16) at AutoImport.addTo (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/auto-import.js:171:56) at Class.postprocessTree (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/index.js:53:55) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25 at Array.reduce () at addonProcessTree (/home/abc/xxx/cba/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32) at EmberApp.addonPostprocessTree (/home/abc/xxx/cba/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ember-cli/lib/broccoli/ember-app.js:606:12) at EmberApp.toTree (/home/abc/xxx/cba/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ember-cli/lib/broccoli/ember-app.js:1331:17) -~- (end) -~-
  • errorType: Build Error
  • location:
    • column: [undefined]
    • file: [undefined]
    • line: [undefined]
    • treeDir: [undefined]
  • message: webpack returned errors to ember-auto-import at WebpackBundler (ember-auto-import-webpack) -~- created here: -~- at new Plugin (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/broccoli-plugin/dist/index.js:47:36) at new WebpackBundler (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/webpack.js:115:9) at AutoImport.makeBundler (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/auto-import.js:153:16) at AutoImport.addTo (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/auto-import.js:171:56) at Class.postprocessTree (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/index.js:53:55) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25 at Array.reduce () at addonProcessTree (/home/abc/xxx/cba/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32) at EmberApp.addonPostprocessTree (/home/abc/xxx/cba/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ember-cli/lib/broccoli/ember-app.js:606:12) at EmberApp.toTree (/home/abc/xxx/cba/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/ember-cli/lib/broccoli/ember-app.js:1331:17) -~- (end) -~-
  • name: Error
  • nodeAnnotation: ember-auto-import-webpack
  • nodeName: WebpackBundler
  • originalErrorMessage: webpack returned errors to ember-auto-import
  • stack: Error: webpack returned errors to ember-auto-import at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-auto-import/js/webpack.js:541:32 at finalCallback (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:500:32) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:578:17 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/HookWebpackError.js:67:2 at Hook.eval [as callAsync] (eval at create (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/Hook.js:18:14) at Cache.storeBuildDependencies (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Cache.js:126:37) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:574:19 at Hook.eval [as callAsync] (eval at create (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/Hook.js:18:14) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:570:23 at Compiler.emitRecords (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:1046:4) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:560:11 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:1009:14 at Hook.eval [as callAsync] (eval at create (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/Hook.js:18:14) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:1006:27 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:2818:7 at done (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/neo-async/async.js:3522:9) at Hook.eval [as callAsync] (eval at create (/home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1) at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/webpack/lib/Compiler.js:835:33 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/graceful-fs/graceful-fs.js:143:16 at /home/abc/xxx/cba/node_modules/.pnpm/[email protected]/node_modules/graceful-fs/graceful-fs.js:61:14 at FSReqCallback.oncomplete (node:fs:192:23)

LuisMacedoKantar avatar Mar 13 '25 08:03 LuisMacedoKantar

@runspired, I just updated to the new version 4.13.0-alpha.6 and also the new warpdrive/build-config 0.0.2, and everything seems to be working now with the setConfig.

LuisMacedoKantar avatar Mar 21 '25 16:03 LuisMacedoKantar

post.comments.splice(0) does not seem to work correctly on a hasMany array? It removes one item instead of clearing the whole array. post.comments.splice(0, post.comments.length) does work

BoussonKarel avatar Mar 24 '25 10:03 BoussonKarel

I had some inflector rules in an initializer:

import Inflector from 'ember-inflector';

export function initialize(/* application */) {
  const inflector = Inflector.inflector;
  inflector.uncountable('price-quote-extra-services');
}

export default {
  name: 'custom-inflector-rules',
  initialize,
};

But this threw errors in my test app where I defined that model:

Image

Image

I ended up just throwing away ember-inflector and used @ember-data/request-utils/string, which was fine for me, but still, a regression.

BoussonKarel avatar Mar 24 '25 11:03 BoussonKarel

@BoussonKarel see item: ember-inflector support initializer needs to be backported

that said I think if you are on latest 4.13 this has now been done, though @nickschot mentioned it seems the initializer fix only works in the app, not in tests ... which is pretty odd.

runspired avatar Mar 24 '25 21:03 runspired

@BoussonKarel see item: ember-inflector support initializer needs to be backported

that said I think if you are on latest 4.13 this has now been done, though @nickschot mentioned it seems the initializer fix only works in the app, not in tests ... which is pretty odd.

Yeah seemed like a potential ordering issue. Not entirely clear. Setting up the inflections in app.js works fine for all scenarios as far as i could see.

edit: I've only tried that with ember-inflector v5+ (so v2 addon version).

nickschot avatar Mar 24 '25 21:03 nickschot

that said I think if you are on latest 4.13 this has now been done, though @nickschot mentioned it seems the initializer fix only works in the app, not in tests ... which is pretty odd.

I am on the latest version (4.13.0-alpha.6). The inflections were defined in an initializer and the models were added in a test.

BoussonKarel avatar Mar 25 '25 07:03 BoussonKarel

if you call createRecord in a test expecting a re-render, you need to await settled

Same goes for .destroyRecord etc, you need an await settled() before asserting properties like isDestroyed or asserting DOM stuff

BoussonKarel avatar Apr 07 '25 13:04 BoussonKarel

I discovered https://github.com/emberjs/data/issues/9970 today when testing 4.13.0-alpha.8.

robbytx avatar Apr 30 '25 20:04 robbytx

Another issue in 4.13.0-alpha.8 is that the relationship.key property appears to be missing in the JSONAPISerializer.serializeBelongsTo method. (Discussed in #ember-data channel.)

This property is present in 5.4.1 and 4.12.8. See https://github.com/ember-cli/ember-new-output/compare/v4.12.3...robbytx:ember-new-output:relationship-key?expand=1 for a minimal repro.

robbytx avatar May 01 '25 20:05 robbytx