Bug in firestore: Cannot read property 'replace' of undefined
See original GitHub issueVersion info
DEBUG: -------------------------------
DEBUG: Ember : 3.18.1
DEBUG: Ember Data : 3.18.0
DEBUG: Firebase : 7.0.0
DEBUG: EmberFire : 3.0.0-rc.6
DEBUG: -------------------------------
I am trying to save a sample record in the following way (record gets saved but throws an error):
const game = this.store.createRecord('game', {
id: Math.round(date.getTime() / 1000),
has_started: 0,
is_over: 0,
player1: 1,
player2: 2,
player3: 3,
player4: 4,
});
await game.save();
This throws an error :
TypeError: Cannot read property 'replace' of undefined
at Cache.func (index.js:64)
at Cache.get (index.js:761)
at decamelize (index.js:167)
at Cache.func (index.js:32)
at Cache.get (index.js:761)
at Object.dasherize (index.js:190)
at normalizeModelName (-private.js:62)
at detectMerge (-private.js:648)
at IdentifierCache.updateRecordIdentifier (-private.js:456)
at Store.didSaveRecord (-private.js:8724)
Model app/models/game.js
import Model, { attr } from '@ember-data/model';
export default class GameModel extends Model {
@attr('boolean') hasStarted;
@attr('boolean') isOver;
@attr() player1;
@attr() player2;
@attr() player3;
@attr() player4;
}
Adapter app/adapters/application.js
import FirestoreAdapter from 'emberfire/adapters/firestore';
export default FirestoreAdapter.extend({
});
Serializer app/serializers/application.js
import FirestoreSerializer from 'emberfire/serializers/firestore';
export default class ApplicationSerializer extends FirestoreSerializer {
}
This is reproducible with the bare minimum configuration.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Bug in firestore: Cannot read property 'replace' of undefined
TypeError : Cannot read property 'replace' of undefined at Cache.func (index.js:64) at Cache.get (index.js:761) at decamelize (index.js:167) ...
Read more >Firebase Function: TypeError: Cannot read property 'replace ...
The error your getting is caused by the body being undefined , so try checking for error before sending back a response:
Read more >Typeerror: Cannot Read Property 'Replace' Of Undefined ...
JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or...
Read more >typeerror: cannot read property 'location' of undefined jest
the ESLint error ESLint: Cannot read property 'replace' of undefined will occur (usually two times). Note: this seems to be new-ish behavior, though...
Read more >Firebase to Google Sheets Error: Cannot read properties of ...
Current facing the below error when setting up Firebase to Google Sheet. Cannot read properties of undefined (reading 'rest').
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
^ And for the Firestore serializer:
@bnetter @mattmcginnis @lalitindoria You can use this patch in your app to keep it working again: https://github.com/firebase/emberfire/pull/600#issuecomment-586595784
./app/serializers/application.js
You can find an implementation here as well: https://github.com/zoltan-nz/library-app/blob/master/app/serializers/application.js