Ember FastBoot Cannot read property 'userAgent' of undefined - javascript

I'm trying to use Ember FastBoot for my application but when I run:
ember fastboot --serve-assets this error is thrown:
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
any help?

The repo you posted contains a number of references to document and window. You will have to use the ember provided facility for detecting the current environment details and implement conditional logic based on whether your pages are being rendered in the browser or not. You can use environment.hasDOM to perform that check.

Related

Circular JSON stringify error without relevant stack trace on Nest.js

The following error is killing my application in production:
/usr/src/app/node_modules/#nestjs/common/services/console-logger.service.js:137
? `${this.colorize('Object:', logLevel)}\n${JSON.stringify(message, (key, value) => typeof value === 'bigint' ? value.toString() : value, 2)}\n`
^
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'Socket'
--- property '_httpMessage' closes the circle
at JSON.stringify (<anonymous>)
at ConsoleLogger.stringifyMessage (/usr/src/app/node_modules/#nestjs/common/services/console-logger.service.js:137:62)
at ConsoleLogger.formatMessage (/usr/src/app/node_modules/#nestjs/common/services/console-logger.service.js:130:29)
at /usr/src/app/node_modules/#nestjs/common/services/console-logger.service.js:122:43
at Array.forEach (<anonymous>)
at ConsoleLogger.printMessages (/usr/src/app/node_modules/#nestjs/common/services/console-logger.service.js:117:18)
at ConsoleLogger.error (/usr/src/app/node_modules/#nestjs/common/services/console-logger.service.js:44:14)
at Logger.error (/usr/src/app/node_modules/#nestjs/common/services/logger.service.js:34:75)
at Logger.descriptor.value (/usr/src/app/node_modules/#nestjs/common/services/logger.service.js:163:27)
at ExceptionsHandler.handleUnknownError (/usr/src/app/node_modules/#nestjs/core/exceptions/base-exception-filter.js:54:43)
I can't reproduce it on development and I don't know what is causing this error. Is there any way to make the stack trace include the source of this error?
I already ran it with DEBUG=*, but it doesn't give me a conclusive answer.
I think the error is happening close to these lines (based on logs), but I can't tell for sure:
this.logger.error(error.toString())
throw new InternalServerErrorException(error.toString())
It doesn't seems to be related, because error.toString() evaluates to [object Object] (useless, but not wrong).
Based on the properties, it looks like probably an AxiosError or some other HTTP client error was thrown directly without being converted into an HttpException that Nest would know how to handle and Nest then tried to log out the error. I would check your uses of HttpService (if you use it) or any other HTTP clients you use. If you still can't find anything, I'd suggest using a different logger than Nest's that can handle circular JSON. My preference is ogma, but I'm also the author of it. pino is another good choice

Zombie.js unable to access dataset property of DOM elements

I have a page which contains a rich-text editor. I used CKEditor for this. You pass it a div element and it loads the editor into that element.
Now I wanted to write integration tests for that page. I am using zombie.js with version 4.2.1 (old, I know, but I'm stuck with it) for that purpose. However, I get an error just trying to load the page. The problem apparently happens while trying to load editor into the div element. This is the relevant output:
[some other resources loading]
zombie GET http://localhost:10003/js/lib/ckeditor.js => 200 +0ms
zombie GET http://localhost:10003/js/pages/categories/init.js => 200 +0ms
zombie http://localhost:10003/js/lib/ckeditor.js:6623
e.dataset.ckeFiller = true;
^
TypeError: Cannot set property 'ckeFiller' of undefined
at au (http://localhost:10003/js/lib/ckeditor.js:6623:37)
at Module.<anonymous> (http://localhost:10003/js/lib/ckeditor.js:7326:24)
at n (http://localhost:10003/js/lib/ckeditor.js:57:22)
at http://localhost:10003/js/lib/ckeditor.js:100:20
at http://localhost:10003/js/lib/ckeditor.js:101:10
at t (http://localhost:10003/js/lib/ckeditor.js:47:258)
at http://localhost:10003/js/lib/ckeditor.js:48:7
at Script.runInContext (vm.js:133:20)
at Object.runInContext (vm.js:311:6)
at window._evaluate (/home/laura/Projekte/fricke/hybristools/node_modules/zombie/lib/document.js:253:75)
in http://localhost:10003/categories +68ms
Debug-Output hier:
undefined
{ http://localhost:10003/js/lib/ckeditor.js:6623
e.dataset.ckeFiller = true;
^
TypeError: Cannot set property 'ckeFiller' of undefined
at au (http://localhost:10003/js/lib/ckeditor.js:6623:37)
at Module.<anonymous> (http://localhost:10003/js/lib/ckeditor.js:7326:24)
at n (http://localhost:10003/js/lib/ckeditor.js:57:22)
at http://localhost:10003/js/lib/ckeditor.js:100:20
at http://localhost:10003/js/lib/ckeditor.js:101:10
at t (http://localhost:10003/js/lib/ckeditor.js:47:258)
at http://localhost:10003/js/lib/ckeditor.js:48:7
at Script.runInContext (vm.js:133:20)
at Object.runInContext (vm.js:311:6)
at window._evaluate (/home/laura/Projekte/fricke/hybristools/node_modules/zombie/lib/document.js:253:75)
in http://localhost:10003/categories
cause:
http://localhost:10003/js/lib/ckeditor.js:6623
e.dataset.ckeFiller = true;
^
TypeError: Cannot set property 'ckeFiller' of undefined
at au (http://localhost:10003/js/lib/ckeditor.js:6623:37)
at Module.<anonymous> (http://localhost:10003/js/lib/ckeditor.js:7326:24)
at n (http://localhost:10003/js/lib/ckeditor.js:57:22)
at http://localhost:10003/js/lib/ckeditor.js:100:20
at http://localhost:10003/js/lib/ckeditor.js:101:10
at t (http://localhost:10003/js/lib/ckeditor.js:47:258)
at http://localhost:10003/js/lib/ckeditor.js:48:7
at Script.runInContext (vm.js:133:20)
at Object.runInContext (vm.js:311:6)
at window._evaluate (/home/laura/Projekte/fricke/hybristools/node_modules/zombie/lib/document.js:253:75)
in http://localhost:10003/categories,
isOperational: true }
I know that the error is not related to CKEditor because I tried it with another rich-text editor, which gave me the exact same error (only the property name was different).
The error apparently happens while trying to set the value of the HTML property "data-cke-filler" of a br element. This is the element:
That element is inserted into the editor at the time of creation, it represents the content of the editor, which is empty at the beginning.
I tried to use zombies debugging capabilites, however, as the error occurs while the site loads I don't really get a chance to output anything useful. As far as I am aware, zombie.js should be able to handle loading this page.
So my question is:
What is causing this error and how can I fix it?
Let me know if you need more information.
Thanks.
Edit:
Here is the code where I load the page (it's written in CoffeeScript):
require 'should'
Browser = require '../../support/browser'
describe 'editor page', ->
browser = new Browser({debug: true})
before (done) ->
browser.debug()
browser.visitLoggedIn('/', {name: 'tester', password: 'secret'})
.then (done) ->
browser.visitPage '/editor' # this is what doesn't work
.then (done) ->
console.log 'page loaded'
.catch (error) ->
console.error error
it 'things should appear', ->
...
The visitLoggedIn method is a custom method that just creates necessary cookies for browsing the application as an authenticated user and visits the page using visitPage. visitPage uses zombies visit method. These work fine in all the other integration tests of this application.
Edit 2:
So I managed to "mock" CKEdtor using this answer. This isn't exactly what I wanted, but I decided to try to work with this for now. However, now I get the exact same error! This time the error is thrown inside my own code:
# These are two functions that are run shortly after inserting the editor into the page,
# so basically while the page is still loading.
getLanguageChoice: -> # This one is executed first
document.getElementById('language').value
getMandantChoice: -> # This one second
document.getElementById('shopClient').dataset.name # The error is thrown here
This is the exact error:
TypeError: Cannot read property 'name' of undefined
at Object.CategoriesView.getMandantChoice (http://localhost:10003/js/pages/categories/view.js:49:59)
at http://localhost:10003/js/pages/categories/app.js:22:97
at process._tickCallback (internal/process/next_tick.js:68:7)
This doesn't make any sense to me. Does this mean that zombie somehow can't access the values of data-* attributes? Maybe someone is knowledgeable about zombie and can provide further insight?
After further looking around with the new insights I gained, I found this ticket on the Github page of the project. It looks like the dataset property is not implemented in an underlying library in the used version. As I am not able to upgrade, it's just not possible to load the page like it is...
To work around this, I will refactor my code to not use the data-* property. This is luckily not tied to too much work in my case.

error happening in thrift

I'm getting this error when running my script. Not sure why this is happening. Seems like there may be a bug in Evernote's Thrift
TypeError: Cannot read property 'length' of undefined
at Buffer.write (buffer.js:733:13)
at Object.BinaryParser.fromString (/Users/sam/Documents/evernote/node_modules/evernote/lib/thrift/protocol/binaryProtocol.js:502:12)
at BinaryProtocol.writeString (/Users/sam/Documents/evernote/node_modules/evernote/lib/thrift/protocol/binaryProtocol.js:148:30)
at BinaryProtocol.writeType (/Users/sam/Documents/evernote/node_modules/evernote/lib/thrift/protocol/binaryProtocol.js:168:25)
at new Thrift.List.write (/Users/sam/Documents/evernote/node_modules/evernote/lib/thrift/thrift.js:275:20)
at new Thrift.Struct.write (/Users/sam/Documents/evernote/node_modules/evernote/lib/thrift/thrift.js:530:17)
at Thrift.Struct.write (/Users/sam/Documents/evernote/node_modules/evernote/lib/thrift/thrift.js:530:17)
at Thrift.Method.sendRequest (/Users/sam/Documents/evernote/node_modules/evernote/lib/thrift/thrift.js:162:15)
at NoteStoreClient.updateNote (/Users/sam/Documents/evernote/node_modules/evernote/lib/thrift/gen-js2/NoteStore.js:1700:8)
at /Users/sam/Documents/evernote/node_modules/evernote/lib/stores.js:106:14
NoteStore#updateNote takes a Note object as an argument. You should be able to instantiate it by new Evernote.Note(). Note that it seems you don't have to set title if you are not going to update it.

Why is the following Meteor/mongodb findOne returning undefined?

Code:
Template.chapterForm.rendered = ->
Meteor.startup ->
currentChapter = Chapters.findOne(
_id: "Wdyxj8pWg2HPzuDuf"
)
console.log currentChapter
console.log currentChapter.content
I get the following output:
undefined
Exception from Tracker afterFlush
function: Cannot read property 'content' of undefined TypeError:
Cannot read property 'content' of undefined
I'm puzzled. Is it a CoffeScript mistake or a Meteor/mongodb mistake?
(I tried moving the code to the top of the file. Still getting undefined)
EDIT:
Strange, if I do
Chapters.findOne({_id: "Wdyxj8pWg2HPzuDuf"});
In the console I do get the object:
Object
following two expression is totally same in coffeescript
Chapters.findOne(
_id: "Wdyxj8pWg2HPzuDuf"
)
Chapters.findOne({_id: "Wdyxj8pWg2HPzuDuf"})
I have no idea why you used 'Meteor.startup ->' in the template instance, it's not the good way. In the Meteor docs, "On a client, the function will run as soon as the DOM is ready." So the findOne action would be run right after the screen was created or rendered. I think it could ruin the Template instances life cycle order, so just use 'created' and 'rendered' cycle.
Additionally from #2, as of life cycle, you should have subscribed the collection before you fetched it (findOne), somewhere parents template or in the router code.
So the conclusion is it seems that there's no data in you browser mini-mongo.
That means you need to check in the browser console with 'Chapters.find().fetch()' command, and then if you can see the data on the console but have still the same error , you should check the life cycle to make the subscribe clearly.

JavaScript error: SCRIPT5007: Unable to get property 'getElementsByTagName'

I am using the following jQuery to get the field value from a Display Form in SharePoint 2013 so I can pass the value along in a URL.
var itemID = $('h3:contains("My ID")').closest('td').next('td').text();
It is working perfectly, but I am getting an error when I inspect the action:
SCRIPT5007: Unable to get property 'getElementsByTagName' of undefined or null reference
File: sp.ui.dialog.js, Line: 2, Column: 22380
This contradicts what is actually occurring, since the code executes. I am running IE11 in IE10 compatibility mode.
I have seen this when the URL being passed to the modal function was invalid. In my case, I has a dynamic URL containing a variable named itemID. I got the error whenever itemID was undefined.
I wish I could elaborate further but all I can comment on is my own observations at this point.

Categories