Jasmine throws minimongo error on Meteor - meteor

My code goes here (in coffeescript):
describe "Chat", ->
it "should contain 1 message after insert()", ->
collection = new Meteor.Collection(null)
collection.insert({username:'guest', message : 'hi'})
expect(collection.find({}).count()).not.toBe(0 )
When runs in Meteor, it complains:
Error: TypeError: Cannot read property '_docs' of undefined
at [object Object].LocalCollection.Cursor._getRawObjects (/Users/user/WebstormProjects/mud-craft/.meteor/local/build/programs/server/packages/minimongo.js:512:18)
at [object Object].LocalCollection.Cursor.count (/Users/user/WebstormProjects/mud-craft/.meteor/local/build/programs/server/packages/minimongo.js:260:15)
at Object.<anonymous> (/Users/user/WebstormProjects/mud-craft/tests/jasmine/server/unit/sample_server_test.coffee:6:5)
But it's ok in product code.

Related

Timber blocks access to edit posts/pages

I'm working on a Wordpress site I did not set up and it is using Timber with a modified Gesso theme. Whenever I go to edit a post or page it loads a blank screen. Nothing appears on the front end but here are the numerous errors from the console:
Uncaught SyntaxError: missing ) after argument list
post.php?post=157&action=edit:87 Uncaught ReferenceError: _ is not defined
at post.php?post=157&action=edit:87
post.php?post=157&action=edit:151 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:151
at post.php?post=157&action=edit:152
post.php?post=157&action=edit:157 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:157
at post.php?post=157&action=edit:168
post.php?post=157&action=edit:188 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:188
at post.php?post=157&action=edit:192
post.php?post=157&action=edit:201 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:201
at post.php?post=157&action=edit:202
post.php?post=157&action=edit:206 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:206
post.php?post=157&action=edit:211 Uncaught ReferenceError: moment is not defined
at post.php?post=157&action=edit:211
post.php?post=157&action=edit:217 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:217
at post.php?post=157&action=edit:218
post.php?post=157&action=edit:226 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:226
at post.php?post=157&action=edit:227
post.php?post=157&action=edit:239 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:239
at post.php?post=157&action=edit:240
post.php?post=157&action=edit:245 Uncaught TypeError: Cannot read property 'editor' of undefined
at post.php?post=157&action=edit:245
post.php?post=157&action=edit:249 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:249
post.php?post=157&action=edit:256 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:256
at post.php?post=157&action=edit:257
post.php?post=157&action=edit:269 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:269
at post.php?post=157&action=edit:270
post.php?post=157&action=edit:277 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:277
at post.php?post=157&action=edit:278
post.php?post=157&action=edit:319 Uncaught ReferenceError: wp is not defined
at post.php?post=157&action=edit:319
post.php?post=157&action=edit:2199 Uncaught ReferenceError: acf is not defined
at post.php?post=157&action=edit:2199
post.php?post=157&action=edit:2203 Uncaught ReferenceError: acf is not defined
at post.php?post=157&action=edit:2203
post.php?post=157&action=edit:2207 Uncaught ReferenceError: acf is not defined
at post.php?post=157&action=edit:2207
at post.php?post=157&action=edit:2212
load-scripts.php?c=1&load[]=hoverIntent,common,admin-bar,heartbeat,postbox,wp-dom-ready,wp-plugins&ver=5.2.4:7 Uncaught TypeError: Cannot read property 'createContext' of undefined
at Module.377 (load-scripts.php?c=1&load[]=hoverIntent,common,admin-bar,heartbeat,postbox,wp-dom-ready,wp-plugins&ver=5.2.4:7)
at n (load-scripts.php?c=1&load[]=hoverIntent,common,admin-bar,heartbeat,postbox,wp-dom-ready,wp-plugins&ver=5.2.4:7)
at wp.plugins.0 (load-scripts.php?c=1&load[]=hoverIntent,common,admin-bar,heartbeat,postbox,wp-dom-ready,wp-plugins&ver=5.2.4:7)
at load-scripts.php?c=1&load[]=hoverIntent,common,admin-bar,heartbeat,postbox,wp-dom-ready,wp-plugins&ver=5.2.4:7
post.php?post=157&action=edit:2237 Uncaught TypeError: Cannot read property 'setLocaleData' of undefined
at post.php?post=157&action=edit:2237
at post.php?post=157&action=edit:2238
post.php?post=157&action=edit:2257 Uncaught TypeError: Cannot read property 'setLocaleData' of undefined
at post.php?post=157&action=edit:2257
at post.php?post=157&action=edit:2258
post.php:2681 Uncaught ReferenceError: tinymce is not defined
at post.php:2681
data.min.js:1 Uncaught TypeError: Cannot read property 'flowRight' of undefined
at Module.363 (data.min.js:1)
at r (data.min.js:1)
at wp.data.0 (data.min.js:1)
at data.min.js:1
shortcode.min.js:1 Uncaught TypeError: Cannot read property 'extend' of undefined
at Module.352 (shortcode.min.js:1)
at n (shortcode.min.js:1)
at wp.shortcode.2 (shortcode.min.js:1)
at shortcode.min.js:1
blocks.min.js:2 Uncaught TypeError: Cannot read property 'combineReducers' of undefined
at Module.362 (blocks.min.js:2)
at r (blocks.min.js:1)
at wp.blocks.0 (blocks.min.js:1)
at blocks.min.js:1
keycodes.min.js:1 Uncaught TypeError: Cannot read property 'mapValues' of undefined
at Module.382 (keycodes.min.js:1)
at r (keycodes.min.js:1)
at wp.keycodes.1 (keycodes.min.js:1)
at keycodes.min.js:1
rich-text.min.js:1 Uncaught TypeError: Cannot read property 'combineReducers' of undefined
at Module.361 (rich-text.min.js:1)
at r (rich-text.min.js:1)
at wp.richText.0 (rich-text.min.js:1)
at rich-text.min.js:1
components.min.js:19 Uncaught TypeError: Cannot read property 'stubTrue' of undefined
at e (components.min.js:19)
at e (components.min.js:19)
at compose.min.js:1
at Module.<anonymous> (components.min.js:19)
at n (components.min.js:1)
at components.min.js:1
at components.min.js:1
core-data.min.js:1 Uncaught TypeError: Cannot read property 'createRegistryControl' of undefined
at Module.364 (core-data.min.js:1)
at r (core-data.min.js:1)
at wp.coreData.132 (core-data.min.js:1)
at core-data.min.js:1
viewport.min.js:1 Uncaught TypeError: Cannot read property 'registerStore' of undefined
at Module.372 (viewport.min.js:1)
at n (viewport.min.js:1)
at wp.viewport.2 (viewport.min.js:1)
at viewport.min.js:1
block-editor.min.js:55 Uncaught TypeError: Cannot read property 'flow' of undefined
at Module.357 (block-editor.min.js:55)
at n (block-editor.min.js:1)
at wp.blockEditor.0 (block-editor.min.js:1)
at block-editor.min.js:1
notices.min.js:1 Uncaught TypeError: Cannot read property 'registerStore' of undefined
at Module.371 (notices.min.js:1)
at r (notices.min.js:1)
at wp.notices.15 (notices.min.js:1)
at notices.min.js:1
nux.min.js:1 Uncaught TypeError: Cannot read property 'combineReducers' of undefined
at Module.375 (nux.min.js:1)
at n (nux.min.js:1)
at wp.nux.0 (nux.min.js:1)
at nux.min.js:1
editor.min.js:17 Uncaught TypeError: Cannot read property 'SETTINGS_DEFAULTS' of undefined
at Module.358 (editor.min.js:17)
at n (editor.min.js:1)
at wp.editor.0 (editor.min.js:1)
at editor.min.js:1
block-library.min.js:23 Uncaught TypeError: Cannot read property 'withFallbackStyles' of undefined
at Module.<anonymous> (block-library.min.js:23)
at n (block-library.min.js:1)
at Module.<anonymous> (block-library.min.js:25)
at Module.<anonymous> (block-library.min.js:25)
at n (block-library.min.js:1)
at block-library.min.js:1
at block-library.min.js:1
editor-block-3-15-1.js:1 Uncaught TypeError: Cannot read property 'Placeholder' of undefined
at Module.<anonymous> (editor-block-3-15-1.js:1)
at r (editor-block-3-15-1.js:1)
at Object.<anonymous> (editor-block-3-15-1.js:1)
at r (editor-block-3-15-1.js:1)
at editor-block-3-15-1.js:1
at editor-block-3-15-1.js:1
compose.min.js:1 Uncaught TypeError: Cannot read property 'flowRight' of undefined
at Module.compose (compose.min.js:1)
at Module.360 (edit-post.min.js:12)
at n (edit-post.min.js:1)
at wp.editPost.0 (edit-post.min.js:1)
at edit-post.min.js:1
format-library.min.js:12 Uncaught TypeError: Cannot read property 'withSpokenMessages' of undefined
at Module.367 (format-library.min.js:12)
at n (format-library.min.js:1)
at wp.formatLibrary.0 (format-library.min.js:1)
at format-library.min.js:1
wp-seo-structured-data-blocks-1240.min.js:1 Uncaught TypeError: Cannot read property 'IconButton' of undefined
at Object.868 (wp-seo-structured-data-blocks-1240.min.js:1)
at f (commons-1240.min.js:1)
at Object.849 (wp-seo-structured-data-blocks-1240.min.js:1)
at f (commons-1240.min.js:1)
at Object.848 (wp-seo-structured-data-blocks-1240.min.js:1)
at f (commons-1240.min.js:1)
at Object.847 (wp-seo-structured-data-blocks-1240.min.js:1)
at f (commons-1240.min.js:1)
at t (commons-1240.min.js:1)
at Array.r [as push] (commons-1240.min.js:1)
annotations.min.js:1 Uncaught TypeError: Cannot read property 'registerStore' of undefined
at Module.370 (annotations.min.js:1)
at e (annotations.min.js:1)
at wp.annotations.1 (annotations.min.js:1)
at annotations.min.js:1
compose.min.js:1 Uncaught TypeError: Cannot read property 'flowRight' of undefined
at Module.compose (compose.min.js:1)
at Object.<anonymous> (wp-seo-post-scraper-1240.min.js:5)
at f (commons-1240.min.js:1)
at Object.<anonymous> (wp-seo-post-scraper-1240.min.js:5)
at f (commons-1240.min.js:1)
at Object.<anonymous> (wp-seo-post-scraper-1240.min.js:5)
at f (commons-1240.min.js:1)
at Object.<anonymous> (wp-seo-post-scraper-1240.min.js:5)
at f (commons-1240.min.js:1)
at Object.<anonymous> (wp-seo-post-scraper-1240.min.js:5)
post.php:2245 Uncaught TypeError: Cannot read property 'initializeEditor' of undefined
at HTMLDocument.<anonymous> (post.php:2245)
If I deactivate the plugin I can access just fine, edit, and then all is normal again when I reactivate. The setup of this host is a little odd so I'm thinking it is a path issue but I can't quite figure out where that should be adjusted looking at the documentation and other folk's issues around the web.
Versions are:
WP 5.2.4
Timber 1.9.4 (that shows a warning not to upgrade. I can paste here if that's helpful but not sure if this is related. I tried updating to the new version and that did not help.)
Advanced Custom Fields PRO 5.8.6 (Might not be relevant but figured I would include in case)
Hosted on Pantheon
Turns out it was a specific way of deferring javascript that was interfering. This is a pretty common function to add to wp but it interferes with Timber. For now I just turned it off but I'm sure if you just added relevant js files to bypass it would be fine but I will probably choose a more robust solution for deferring js going forward.
function defer_parsing_of_js ( $url ) {
if ( FALSE === strpos( $url, '.js' ) ) return $url;
if ( strpos( $url, 'jquery.js' ) ) return $url;
return "$url' defer ";
}
add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );

NzPaginationComponent got TypeError: templateRef.createEmbeddedView is not a function

After I update ng-zorro-antd to Version 1.1.1, and Angular to version 6.0.7, I got the following error for NzPaginationComponent.html:1 :
ERROR TypeError: templateRef.createEmbeddedView is not a function
at ViewContainerRef_.push../node_modules/#angular/core/fesm5/core.js.ViewContainerRef_.createEmbeddedView (core.js:8559)
at NgTemplateOutlet.push../node_modules/#angular/common/fesm5/common.js.NgTemplateOutlet.ngOnChanges (common.js:3834)
at checkAndUpdateDirectiveInline (core.js:9038)
at checkAndUpdateNodeInline (core.js:10306)
at checkAndUpdateNode (core.js:10268)
at debugCheckAndUpdateNode (core.js:10901)
at debugCheckDirectivesFn (core.js:10861)
at Object.eval [as updateDirectives] (NzPaginationComponent.html:1)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:10853)
at checkAndUpdateView (core.js:10250).
Anything I missed to update or I need to amend my code?
may be you should have a look option [nzShowTotal], it should be specified a template.
[nzShowTotal]="totalTpl"
......
<ng-template #totalTpl let-range="range" let-total>{{ 'Total: ' + total}}</ng-template>

Meteor server side call to Ethereum node

I try to interact with Ethereum node via web3 lib. (meteor add ethereum:web3)
Meteor 1.5.4.1
lib.js:
if (typeof web3 === ‘undefined’){
web3 = new Web3(new Web3.providers.HttpProvider(‘http://127.0.0.1:21045’));
}
main.js:
web3.eth.defaultContractEvent = “0x*************************************”;
contract_event = web3.eth.contract(abi_event).at(web3.eth.defaultContractEvent);
var events = contract_event.allEvents({fromBlock: 0, toBlock: ‘latest’});
get error at last line
C:\Users***\AppData\Local.meteor\packages\meteor-tool\1.5.2_2\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\future.js:280
throw(ex);
^
TypeError: XHR2 is not a function
at [object Object].HttpProvider.prepareRequest (packages\ethereum_web3.js:4315:15)
at [object Object].HttpProvider.sendAsync (packages\ethereum_web3.js:4364:22)
at [object Object].RequestManager.sendAsync (packages\ethereum_web3.js:6369:19)
at Object.send [as newFilter] (packages\ethereum_web3.js:5080:42)
at new Filter (packages\ethereum_web3.js:3568:25)
at [object Object].AllSolidityEvents.execute (packages\ethereum_web3.js:2716:12)
at server/main.js:135:30
at Function.time (C:\***\.meteor\local\build\programs\server\profile.js:309:28)
at C:\***\.meteor\local\build\programs\server\boot.js:348:13
at C:\***\.meteor\local\build\programs\server\boot.js:389:5
Exited with code: 1
what is the problem?

Meteor & Polymer 1.0 - Template.dynamic using helper is not working

I am trying to play around mixing Polymer (1.0) & Meteor (1.1.0.2). I am trying to use Template.dynamic (http://docs.meteor.com/#/full/template_dynamic) and trying to set the value of template name using helpers as {{> Template.dynamic template=whichMainPanelHelper }} I am getting the below exception:
Exception from Tracker recompute function:
debug.js:41 Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at Error (native)
at DOMRange.detach (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:512:24)
at DOMRange.setMembers (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:471:12)
at doMaterialize (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2019:22)
at Object.Tracker.nonreactive (https://socioui-rohanray.c9.io/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12)
at doRender (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2015:17)
at https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1865:18
at Function.Template._withTemplateInstanceFunc (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12)
at https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1864:29
at Object.Blaze._withCurrentView (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:12)
globalClient.js?2215a2ab608267b0be3f49b7779cbbe0e07bea5b:4 helper : whichMainPanel : drawerPanelMain
debug.js:41 Exception from Tracker recompute function:
debug.js:41 Error: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
at Error (native)
at DOMRange.detach (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:512:24)
at DOMRange.setMembers (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:471:12)
at doMaterialize (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2019:22)
at Object.Tracker.nonreactive (https://socioui-rohanray.c9.io/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:593:12)
at doRender (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2015:17)
at https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1865:18
at Function.Template._withTemplateInstanceFunc (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:12)
at https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1864:29
at Object.Blaze._withCurrentView (https://socioui-rohanray.c9.io/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:12)
I have done a repo in Cloud 9 # https://ide.c9.io/rohanray/socioui
can be checked live # https://socioui-rohanray.c9.io

JSON will not insert into Meteor Collection (even with Fiber or bindEnvironment)

I realize that similar topics have been discussed, I have browsed through them all and tried to mimic solutions for about 4 hours but none of them seem to solve the problem. I would not have posted this with having exhausted any potential solution I could find.
I am trying to convert a large csv to JSON and then insert it into my Meteor collection following the conversion.
Here is my code using the Meteor.bindElement approach:
if Meteor.isServer
#Fiber = Meteor.npmRequire("fibers")
Meteor.startup ->
#Converter Class
if Data.find().count() is 0
Converter = Meteor.npmRequire('csvtojson').core.Converter
fs = Meteor.npmRequire('fs')
csvFileName = '/Path/To/My/File.csv'
fileStream = fs.createReadStream(csvFileName)
#new converter instance
csvConverter = new Converter(constructResult: true)
#end_parsed will be emitted once parsing finished
csvConverter.on "end_parsed", (jsonObj) ->
console.log jsonObj
boundFunction = Meteor.bindEnvironment(->
Data.insert jsonObj
return
, (e) ->
throw e
return
)
insertToDB boundFunction
#read from file
fileStream.pipe csvConverter
return
After parsing I am able to log the JSON just fine but when I try to add it to the collection like this:
csvConverter.on "end_parsed", (jsonObj) ->
console.log jsonObj
Data.insert jsonObj
I get the error:
throw new Error("Meteor code must always run within a Fiber. " +
W20141112-20:08:44.306(-8)? (STDERR) ^
W20141112-20:08:44.306(-8)? (STDERR) Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.
W20141112-20:08:44.306(-8)? (STDERR) at Object.Meteor._nodeCodeMustBeInFiber (packages/meteor/dynamics_nodejs.js:9)
W20141112-20:08:44.306(-8)? (STDERR) at _.extend.get (packages/meteor/dynamics_nodejs.js:21)
W20141112-20:08:44.306(-8)? (STDERR) at Object.DDP.randomStream (packages/ddp/random_stream.js:69)
W20141112-20:08:44.306(-8)? (STDERR) at self._makeNewID (packages/mongo/collection.js:72)
W20141112-20:08:44.306(-8)? (STDERR) at Mongo.Collection.(anonymous function) [as insert] (packages/mongo/collection.js:485)
W20141112-20:08:44.307(-8)? (STDERR) at csvAdv.<anonymous> (server/startup.coffee:16:13)
W20141112-20:08:44.307(-8)? (STDERR) at csvAdv.emit (events.js:95:17)
W20141112-20:08:44.307(-8)? (STDERR) at csvAdv.<anonymous> (/Users/samuel_chordas/CurrentClasses/CSCI477a/JPL/JataTwo/packages/npm-container/.build.npm-container/npm/node_modules/csvtojson/libs/core/init_onend.js:9:10)
W20141112-20:08:44.307(-8)? (STDERR) at csvAdv.emit (events.js:117:20)
W20141112-20:08:44.307(-8)? (STDERR) at _stream_readable.js:929:16
=> Exited with code: 8
Which I was able to get rid of by wrapping the function in a fiber with the following code but it DOES NOT write to my collection:
if Meteor.isServer
#Fiber = Meteor.npmRequire("fibers")
Meteor.startup ->
#Converter Class
if Data.find().count() is 0
Converter = Meteor.npmRequire('csvtojson').core.Converter
fs = Meteor.npmRequire('fs')
csvFileName = '/Path/To/My/File.csv'
fileStream = fs.createReadStream(csvFileName)
#new converter instance
csvConverter = new Converter(constructResult: true)
#end_parsed will be emitted once parsing finished
csvConverter.on "end_parsed", (jsonObj) ->
Fiber ->
Data.insert jsonObj
return
fileStream.pipe csvConverter
return
So I tried resorting to using the bindEnvironment as shown in the first block of code which results in the same "Error("Meteor code must always run within a Fiber" error.
Here is my collection in my /lib folder:
#Data = new Mongo.Collection 'data'
I am pretty new to Meteor Javascript and Coffescript so any feedback would be appreciated.
Also I would like to add that I can't get .run() to work on Fiber.
Try moving the definition of boundFunction outside of the end_parsed event handler.
boundFunction = Meteor.bindEnvironment((jsonObj) ->
Data.insert jsonObj
return
, (e) ->
throw e
)
csvConverter.on "end_parsed", (jsonObj) ->
console.log jsonObj
boundFunction jsonObj
return
I suspect the "Meteor code must always run within a Fiber." error is not coming from Data.insert but from Meteor.bindEnvironment itself. Meteor.bindEnvironment
is called from inside a "Meteor context"
takes a function
binds that function to the same "Meteor context" that bindEnvironment was called from
In your implementation, by the time you call bindEnvironment, the "Meteor context" has already been lost, so bindEnvironment can't do anything to help.

Resources