I've stumbled upon an infinite loop in the fields() method on the legacy Model schema provider in the legacy package. This only happens in production.
When calling fields with a nonexistent type, it calls _loadModelSchema.
|
fields(resource: ResourceKey | { type: string }): Map<string, LegacyField> { |
|
const type = normalizeModelName(resource.type); |
|
|
|
if (!this._schemas.has(type)) { |
|
this._loadModelSchema(type); |
|
} |
|
|
|
return this._schemas.get(type)!.fields; |
This then calls this.store.modelFor. Because the type does not exist, it calls super.modelFor, which returns a shim:
|
StoreKlass.prototype.modelFor = function <T>( |
|
type: T extends TypedRecordInstance ? TypeFromInstance<T> : string |
|
): ModelSchema<T> { |
|
assert(`Attempted to call store.modelFor(), but the store instance has already been destroyed.`, !this.isDestroyed); |
|
assert(`You need to pass <type> to the store's modelFor method`, typeof type === 'string' && type.length); |
|
assert(`No model was found for '${type}' and no schema handles the type`, this.schema.hasResource({ type })); |
|
|
|
return getShimClass<T>(this, type); |
And this shim calls this.__store.schema.fields, causing a loop:
|
export class ShimModelClass<T = unknown> implements ModelSchema<T> { |
|
declare __store: Store; |
|
declare modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string; |
|
constructor(store: Store, modelName: T extends TypedRecordInstance ? TypeFromInstance<T> : string) { |
|
this.__store = store; |
|
this.modelName = modelName; |
|
} |
|
|
|
get fields(): Map<KeyOrString<T>, 'attribute' | 'belongsTo' | 'hasMany'> { |
|
const fields = new Map<KeyOrString<T>, 'attribute' | 'belongsTo' | 'hasMany'>(); |
|
const fieldSchemas = this.__store.schema.fields({ type: this.modelName }); |
|
|
I've stumbled upon an infinite loop in the fields() method on the legacy Model schema provider in the legacy package. This only happens in production.
When calling fields with a nonexistent type, it calls _loadModelSchema.
warp-drive/warp-drive-packages/legacy/src/model/-private/schema-provider.ts
Lines 141 to 148 in b3372e5
This then calls
this.store.modelFor. Because the type does not exist, it callssuper.modelFor, which returns a shim:warp-drive/warp-drive-packages/legacy/src/store.ts
Lines 206 to 213 in b3372e5
And this shim calls
this.__store.schema.fields, causing a loop:warp-drive/warp-drive-packages/core/src/store/deprecated/-private.ts
Lines 410 to 421 in b3372e5