question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using torii with FastBoot

See original GitHub issue

I can’t seem to properly run this in a FastBoot app.

Torii works fine, but once I turn my app into FastBoot, I’m getting DOM requirement errors.

ReferenceError: document is not defined

There was an error running your app in fastboot. More info about the error: 
 ReferenceError: document is not defined
    at loadScript (/tmp/broccoli_merge_trees-output_path-foo.tmp/assets/addon-tree-output/torii/providers/-private/utils.js:24:1)
    at Ember.RSVP.Promise.then.window.fbAsyncInit (/tmp/broccoli_merge_trees-output_path-foo.tmp/assets/addon-tree-output/torii/providers/facebook-connect.js:34:1)
    at initializePromise (/tmp/broccoli_merge_trees-output_path-foo.tmp/assets/rsvp.js:397:1)
    at new Promise (/tmp/broccoli_merge_trees-output_path-foo.tmp/assets/rsvp.js:877:1)
    at fbLoad (/tmp/broccoli_merge_trees-output_path-foo.tmp/assets/addon-tree-output/torii/providers/facebook-connect.js:26:1)
    at Class.init (/tmp/broccoli_merge_trees-output_path-foo.tmp/assets/addon-tree-output/torii/providers/facebook-connect.js:84:1)

Ember 3.5 Torii 0.10.1

This is happening when I’m using the facebook-connect adapter, but this.get('torii).open('facebook-connect') is only fired within a user activated action, so I don’t understand why facebook-connect.js is running serverside (FastBoot) at all.

Is there a specific way this needs to be set up, or is the torii plugin simply incompatible with FastBoot?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

1reaction
jkeencommented, Apr 24, 2019

Future travelers using torii ^0.10, you’re gonna want the fix below since it now eager loads the FB connect code in the init hook. Also to save you from the pain I just experienced, the fix above has a casing typo: isFastBoot needs that very crucial capital B! 😅

import FacebookConnectProvider from 'torii/providers/facebook-connect';
import { inject as service } from '@ember/service';
import { reads } from '@ember/object/computed';
import { get } from '@ember/object';

export default FacebookConnectProvider.extend({
  fastboot: service(),
  isFastBoot: reads('fastboot.isFastBoot'),

  init() {
    if(get(this, 'isFastBoot')) {
      return;
    }
    else {
      this._super(...arguments);
    }
  },
});
1reaction
ehubbellcommented, Feb 20, 2019

@Redsandro I got this to work on my end. You basically need to block against the FacebookConnectProvider not being available when the app boots in fastboot. Then, after it’s loaded the FacebookConnectProvider service will go through. Not sure what’s happening in the fetch() call but something in that call breaks the build.

Here’s what you need:

Add the following to torii-providers/facebook-connect.js

import FacebookConnectProvider from 'torii/providers/facebook-connect';
import { inject as service } from '@ember/service';
import { reads } from '@ember/object/computed';

export default FacebookConnectProvider.extend({
  	// Services
  fastboot: service(),

  
  // Properties
  isFastboot: reads('fastboot.isFastboot'),

  fetch(data) {
    if(get(this, 'isFastboot')) {
      return;
    }
    return data;
  }
});

Let me know any questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to use Torii with FastBoot in Ember?
I'm using Torii 0.10.1 with Ember 3.5 in order to use facebook-connect by injecting the torii service into the controller.
Read more >
Issues · Vestorly/torii - GitHub
A set of clean abstractions for authentication in Ember.js - Issues ... Vestorly / torii Public ... Using torii with FastBoot.
Read more >
Why Japan's Tiniest Torii Gate is Dangerously Small - YouTube
To pass through a Torii gate is to pass through into a sacred world. Unfortunately, Japan's tiniest torii gate is so unbelievably small, ......
Read more >
The 5 Things You Need to Know Before You Visit a Shrine
Here are five essential tips to get the most out of your visit to a Shrine. How to walk through a torii gate:...
Read more >
temple 3d model free
Free 3D greek temple models for download, files in 3ds, max, c4d, ... Hindu Temple #Hindu #India #Temple. fastboot usage unknown reboot ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found