Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastBoot support: ReferenceError: navigator is not defined #14

Closed
scottwernervt opened this issue Jun 8, 2017 · 7 comments · Fixed by #16
Closed

FastBoot support: ReferenceError: navigator is not defined #14

scottwernervt opened this issue Jun 8, 2017 · 7 comments · Fixed by #16

Comments

@scottwernervt
Copy link

scottwernervt commented Jun 8, 2017

Instructions

  1. Clone ember-popper
  2. npm install
  3. npm install ember-cli-fastboot --save-dev
  4. ember serve (depreciated ember fastboot --serve-assets)
ReferenceError: navigator is not defined
    at /home/swerner/development/ember-popper/tmp/src/popper/utils/debounce.js:7:20
    at nativeHints (/home/swerner/development/ember-popper/tmp/broccoli_merge_trees-output_path-G2ltQSK1.tmp/assets/vendor.js:62757:19)
    at /home/swerner/development/ember-popper/tmp/broccoli_merge_trees-output_path-G2ltQSK1.tmp/assets/vendor.js:62758:2
    at ContextifyScript.Script.runInContext (vm.js:32:29)
    at VMSandbox.eval (/home/swerner/development/ember-popper/node_modules/fastboot/src/vm-sandbox.js:14:14)
    at /home/swerner/development/ember-popper/node_modules/fastboot/src/ember-app.js:142:15
    at Array.forEach (native)
    at EmberApp.loadAppFiles (/home/swerner/development/ember-popper/node_modules/fastboot/src/ember-app.js:139:21)
    at EmberApp.retrieveSandboxedApp (/home/swerner/development/ember-popper/node_modules/fastboot/src/ember-app.js:187:10)
    at new EmberApp (/home/swerner/development/ember-popper/node_modules/fastboot/src/ember-app.js:50:21)
    at FastBoot._buildEmberApp (/home/swerner/development/ember-popper/node_modules/fastboot/src/index.js:114:17)
    at new FastBoot (/home/swerner/development/ember-popper/node_modules/fastboot/src/index.js:52:10)
    at app.use (/home/swerner/development/ember-popper/node_modules/ember-cli-fastboot/index.js:233:29)
    at Layer.handle [as handle_request] (/home/swerner/development/ember-popper/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/home/swerner/development/ember-popper/node_modules/express/lib/router/index.js:317:13)
    at /home/swerner/development/ember-popper/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/home/swerner/development/ember-popper/node_modules/express/lib/router/index.js:335:12)
    at next (/home/swerner/development/ember-popper/node_modules/express/lib/router/index.js:275:10)
    at err (/home/swerner/development/ember-popper/node_modules/ember-cli/lib/tasks/server/middleware/broccoli-watcher/index.js:54:11)
    at watcher.then.errorHandler.buildError (/home/swerner/development/ember-popper/node_modules/broccoli-middleware/lib/watcher-middleware.js:35:7)
    at tryCatch (/home/swerner/development/ember-popper/node_modules/rsvp/dist/lib/rsvp/-internal.js:216:12)
    at invokeCallback (/home/swerner/development/ember-popper/node_modules/rsvp/dist/lib/rsvp/-internal.js:231:13)
    at /home/swerner/development/ember-popper/node_modules/rsvp/dist/lib/rsvp/then.js:29:16
    at flush (/home/swerner/development/ember-popper/node_modules/rsvp/dist/lib/rsvp/asap.js:85:5)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)

References

I am working on a pull request for ember-popper and ember-attacher to eliminate errors thrown in fastboot sandbox.

@scottwernervt
Copy link
Author

@kybishop I am encountering a failing test when running ember test on the master branch. I cannot figure out why ember-popper is not rendering, any ideas?

not ok 7 Chrome 58.0 - Integration | Component | ember popper: it renders
    ---
        actual: >
            
        expected: >
            template block text
        stack: >
                at Object.<anonymous> (http://localhost:7357/assets/tests.js:133:12)
                at runTest (http://localhost:7357/assets/test-support.js:3295:30)
                at Test.run (http://localhost:7357/assets/test-support.js:3281:6)
                at http://localhost:7357/assets/test-support.js:3473:12
                at Object.advance (http://localhost:7357/assets/test-support.js:2958:26)
                at begin (http://localhost:7357/assets/test-support.js:4654:20)
        Log: |
    ...

integration - component - ember popper - it renders

@kybishop
Copy link
Owner

Hey @scottwernervt, I haven't done too much work with Fastboot, but will start looking into this on Sunday.

@scottwernervt
Copy link
Author

@kybishop I created a pull request #15 to support the fastboot environment and fix the failing test.

@FezVrasta
Copy link

have you tried the most recent version of Popper.js? I don't think it should throw errors if imported in a non browser environment

@scottwernervt
Copy link
Author

@FezVrasta Thanks for the heads up, I will try upgrading popper and running with fastboot.

@scottwernervt
Copy link
Author

After upgrading ember-popper@^1.10.2 and ember-cli-fastboot@^1.0.0-rc.4, I encounter a new error with navigator not being defined.

App is being served by FastBoot
/home/swerner/development/ember-popper/tmp/broccoli_merge_trees-output_path-QjmQIBcg.tmp/assets/vendor.js:62791
  if (isBrowser && navigator.userAgent.indexOf(longerTimeoutBrowsers[i]) >= 0) {
                   ^

ReferenceError: navigator is not defined
    at /home/swerner/development/ember-popper/tmp/src/popper/utils/debounce.js:7:20
    at nativeHints (/home/swerner/development/ember-popper/tmp/broccoli_merge_trees-output_path-QjmQIBcg.tmp/assets/vendor.js:62769:19)
    at /home/swerner/development/ember-popper/tmp/broccoli_merge_trees-output_path-QjmQIBcg.tmp/assets/vendor.js:62770:2
    at ContextifyScript.Script.runInContext (vm.js:53:29)
    at VMSandbox.eval (/home/swerner/development/ember-popper/node_modules/fastboot/src/vm-sandbox.js:14:14)
    at /home/swerner/development/ember-popper/node_modules/fastboot/src/ember-app.js:142:15

@FezVrasta
Copy link

I wonder why isBrowser is set to true in FastBoot.. It simply checks for window to being different from undefined.

I don't know how FastBoot works, but if it's similar to React SSR then, window in the Node env should be undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants