mikkopaderes / ember-cloud-firestore-adapter

Unofficial Ember Data Adapter and Serializer for Cloud Firestore
MIT License
69 stars 17 forks source link

Adapter Options Real Time Tracker breaks in Fastboot #103

Closed alexmasita closed 5 years ago

alexmasita commented 5 years ago

Hi @mikkopaderes. Have been refactoring my app to clean out the fastboot checks. Have hit a snug that appears related to the real time tracker that you enable in the route model as seen here:

  model(_params) {
    return this.store.findRecord('rider', get(this, 'session.data.authenticated.user.uid'), {
      adapterOptions: {
        isRealtime: true //When enabled breaks the fastboot runtime but loads correctly on client
      }
    });
  }

The error I receive is the following:

DEPRECATION: Attempted to call store.peekRecord(), but the store instance has already been destroyed. [deprecation id: ember-data:method-calls-on-destroyed-store]
        at logDeprecationStackTrace (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/deprecate.js:103:1)
        at HANDLERS.(anonymous function) (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/handlers.js:23:1)
        at raiseOnDeprecation (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/deprecate.js:130:1)
        at HANDLERS.(anonymous function) (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/handlers.js:23:1)
        at invoke (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/handlers.js:35:1)
        at Object.deprecate (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/deprecate.js:168:1)
        at assertDestroyedStore (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/addon-tree-output/ember-data/-private.js:12941:1)
        at Class.peekRecord (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/addon-tree-output/ember-data/-private.js:11016:1)
        at Object.docRef.onSnapshot.docSnapshot [as next] (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/addon-tree-output/ember-cloud-firestore-adapter/utils/realtime-tracker.js:39:1)
        at next (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/node_modules/@firebase/firestore/src/api/database.ts:1135:20)
        at Timeout._onTimeout (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/node_modules/@firebase/firestore/src/util/async_observer.ts:51:11)
        at ontimeout (timers.js:436:11)
        at tryOnTimeout (timers.js:300:5)
        at listOnTimeout (timers.js:263:5)
        at Timer.processTimers (timers.js:223:10)
DEPRECATION: Attempted to call store.hasRecordForId(), but the store instance has already been destroyed. [deprecation id: ember-data:method-calls-on-destroyed-store]
        at logDeprecationStackTrace (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/deprecate.js:103:1)
        at HANDLERS.(anonymous function) (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/handlers.js:23:1)
        at raiseOnDeprecation (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/deprecate.js:130:1)
        at HANDLERS.(anonymous function) (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/handlers.js:23:1)
        at invoke (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/handlers.js:35:1)
        at Object.deprecate (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/@ember/debug/lib/deprecate.js:168:1)
        at assertDestroyedStore (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/addon-tree-output/ember-data/-private.js:12941:1)
        at Class.hasRecordForId (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/addon-tree-output/ember-data/-private.js:11072:1)
        at Class.peekRecord (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/addon-tree-output/ember-data/-private.js:11024:1)
        at Object.docRef.onSnapshot.docSnapshot [as next] (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/dist/assets/addon-tree-output/ember-cloud-firestore-adapter/utils/realtime-tracker.js:39:1)
        at next (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/node_modules/@firebase/firestore/src/api/database.ts:1135:20)
        at Timeout._onTimeout (/Users/alexmasita/External/Personal/projects/Ember-Apps/mobile-services-app/node_modules/@firebase/firestore/src/util/async_observer.ts:51:11)
        at ontimeout (timers.js:436:11)
        at tryOnTimeout (timers.js:300:5)
        at listOnTimeout (timers.js:263:5)
        at Timer.processTimers (timers.js:223:10)

I discovered the error disappears when I remove the following adapter options setting:

adapterOptions: {
        isRealtime: true
      }

I however need the real time aspects on the client. Might you know a work-around for this?

mikkopaderes commented 5 years ago

I intended to disable realtime listeners in FastBoot but it seems I forgot to implement it. I'll make a fix for this. Thanks for reporting! šŸ‘