pitchtarget / ember-cli-facebook-js-sdk

Simple Facebook SDK for Javascript addon for your Ember CLI app.
MIT License
29 stars 15 forks source link

Fastboot Support #20

Open rydn opened 7 years ago

rydn commented 7 years ago

Currently if we run fast boot with this module included the following error occurs:

Error while processing route: main Cannot read property 'getScript' of undefined TypeError: Cannot read property 'getScript' of undefined
    at FBInit.fbInitPromise._ember.default.RSVP.Promise.then.window.fbAsyncInit (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:73010:28)
    at initializePromise (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:69123:7)
    at new Promise (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:69611:33)
    at Class.FBInit (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:73005:28)
    at Class.beforeModel (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/stage-360-preregistration.js:577:26)
    at applyHook (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:66590:28)
    at C.runSharedModelHook (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:67209:18)
    at C.runBeforeModelHook (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:67182:17)
    at /home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:66446:15
    at tryCatch (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:69073:14)
    at invokeCallback (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:69088:15)
    at publish (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:69056:9)
    at /home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:48960:16
    at invokeWithOnError (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:10889:16)
    at Queue.flush (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:10948:9)
    at DeferredActionQueues.flush (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:11072:15)
    at Backburner.end (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:11142:23)
    at Timeout._onTimeout (/home/ryan/Dev/Projects/stage-360-preregistration/dist/fastboot/vendor.js:11708:16)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

Is this the facebook sdk assuming its in a browser or is this the module making the call to getScript?

bugant commented 7 years ago

@rydn this is the FB JS SDK trying to do the init, so yes it need to be in a browser. So here the problem is that someone is calling the FBInit function (https://github.com/pitchtarget/ember-cli-facebook-js-sdk/blob/master/addon/services/fb.js#L6). Please, let me know how can I help to solve the issue.

rydn commented 7 years ago

@bugant Assuming the Facebook SDK isn't touching browser specific stuff it would it not be possible to use something like ember-network and then eval'ing the returned text, seems unlikely to me.

Alternatively, why can't it just check isFastboot from the fast boot service?

joelalejandro commented 7 years ago

@rydn @bugant Otherwise, is it possible to set FB = { skipInit: true} from the config/environment if the app's rendering in fast boot mode?