Giter Site home page Giter Site logo

Comments (5)

teckays avatar teckays commented on July 26, 2024

UPDATE
I've tried using ember-cli-fastboot same error:

$ ember fastboot --serve-assets

Cannot read property 'userAgent' of undefined
TypeError: Cannot read property 'userAgent' of undefined
    at Object.125.global/document (<anonymous>:121923:53)
    at s (<anonymous>:104896:621)
    at <anonymous>:104896:672
    at Object.106../big-play-button.js (<anonymous>:113849:23)
    at s (<anonymous>:104896:621)
    at <anonymous>:104896:672
    at Object.139.../../src/js/utils/merge-options.js (<anonymous>:123824:15)
    at s (<anonymous>:104896:621)
    at e (<anonymous>:104896:792)
    at <anonymous>:104896:810
59:vidler andreistalbe$

from fastboot.

teckays avatar teckays commented on July 26, 2024

UPDATE 2

OK, the error was cause by video.js component, the plugin is using document and window to extract different types of data from the browser, userAgent in this case, however, fastboot being server-side doesn't know about these instances. Is there a way to safely build these dependencies? Some of the components are totally intended for client side environment so they should be skipped somehow. Is there a way to make it work on the current version of ember-fastboot-server?

from fastboot.

jasonmit avatar jasonmit commented on July 26, 2024

Some of the components are totally intended for client side environment so they should be skipped somehow

You would need to guard against the navigator being available before accessing it since it doesn't look like the sandbox environment shims it.

https://github.com/ember-fastboot/ember-fastboot-server/blob/master/lib/ember-app.js#L71-L82

from fastboot.

teckays avatar teckays commented on July 26, 2024

@jasonmit I can't think of a general solution that would solve this problem in particular and all others that may occur with other custom ember components. Ensuring window.navigator exists before it's tried to be accessed requires me to change this 3rd party library which leads to more errors down the road because the userAgent is used on bootstrap the component. Setting window.navigator.userAgent to a default value might do the trick rather than ensuring it exists.

As a possible solution, can this be shimmed in the createSandbox()?

from fastboot.

tomdale avatar tomdale commented on July 26, 2024

Closing this for now; let's make sure we cover things like this in the upgrade guide.

from fastboot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.