TypeError: Cannot destructure property 'createNode' of 'boundActionCreators' as it is undefined - google-cloud-firestore

Can anyone help with following error ?
ERROR #11321 PLUGIN
"gatsby-source-firestore" threw an error while running the sourceNodes lifecycle:
Cannot destructure property 'createNode' of 'boundActionCreators' as it is undefined.
24 | const db = firebase.firestore();
25 |
26 | const { createNode, createNodeField } = boundActionCreators;
^
27 |
28 | const promises = types.map(
29 | async ({ collection, type, populate, map = node => node }) => {
File: node_modules\gatsby-source-firestore\gatsby-node.js:26:11
TypeError: Cannot destructure property 'createNode' of 'boundActionCreators' as it is undefined.

Replacing boundActionCreators by actions in gatsby-node.js present in node modules/gatsby-source-firestore
worked

Related

How to check for level in react-testing-library?

I have a heading <h4>Big offer!</h4> on the page, when I first ran my tests I got:
Expected: "Big offer!"
Received: <h4>Big offer!</h4>
35 | const switchToggle = screen.getByRole('checkbox');
36 | expect(switchToggle.checked).toEqual(true);
> 37 | expect(titleEl).toEqual(title);
Ok, it get's correct file, so I changed my code to actually check heading level and text, but it failed:
Expected: "Big offer!"
Received: undefined
35 | const switchToggle = screen.getByRole('checkbox');
36 | expect(switchToggle.checked).toEqual(true);
> 37 | expect(titleEl.name).toEqual(title);
| ^
38 | expect(titleEl.level).toEqual(4);
I always thought that .name is equal to getByText(). I commented out a line and tried checking for level, and it failed again:
Expected: 4
Received: undefined
36 | expect(switchToggle.checked).toEqual(true);
37 | //expect(titleEl.name).toEqual(title);
> 38 | expect(titleEl.level).toEqual(4);
I don't understand why my test cases failed. Code for test was:
const title = 'Big offer!';
render(<Component title={title}/>);
const titleEl = screen.getByRole('heading');
expect(titleEl).toEqual(title);
expect(titleEl.level).toEqual(4);
It wont work because screen.getByRole (or others querys) returns an HTMLElement (in your case returns a HTMLHeadingElement that inherits HTMLElement). And it doesnt have name or level properties. You can check more here.
To check the text rendered you should use:
expect(titleEl).toHaveTextContent(title);
And for h4 type check you just need to filter it on query:
const titleEl = screen.getByRole('heading', { level: 4 });
The full test:
it('test search input', async () => {
const title = 'Big offer!';
render(<SearchBox title={title} />);
const titleEl = screen.getByRole('heading', { level: 4 });
expect(titleEl).toBeInTheDocument();
expect(titleEl).toHaveTextContent(title);
});

MongoDB Visual Studio Code extension: how to find by ObjectId

I'm using the following extension:
https://code.visualstudio.com/docs/azure/mongodb
To perform queries and light data transformation against a Mongo database. I'm having trouble working out how to issue a find request which matches an ObjectId.
I tried:
db.Epochs.find({
'ModelId': '624616797870316ac1432d52'
}).sort({'End': -1})
This results in an empty result set (this ID definitely exists because I copied that value from Compass.
I tried:
db.Epochs.find({
'ModelId': ObjectId'624616797870316ac1432d52')
}).sort({'End': -1})
Which results in the following error:
Unexpected token, expected "," (15:23) 13 | 14 | db.Epochs.find({ > 15 | 'ModelId': ObjectId('624616797870316ac1432d52') | ^ 16 | }).sort({'End': -1}) 17 | 18 | //'EndLogs._impl': { '$exists': true}
I tried adding the NodeJS driver setup calls like:
var Db = require('mongodb').Db,
MongoClient = require('mongodb').MongoClient,
Server = require('mongodb').Server,
ReplSetServers = require('mongodb').ReplSetServers,
ObjectID = require('mongodb').ObjectID,
Binary = require('mongodb').Binary,
GridStore = require('mongodb').GridStore,
Grid = require('mongodb').Grid,
Code = require('mongodb').Code,
BSON = require('mongodb').pure().BSON,
assert = require('assert');
Which errors with:
Cannot find module 'mongodb' Require stack: - c:\Users\Ian\.vscode\extensions\mongodb.mongodb-vscode-0.9.2\dist\languageServerWorker.js
Finally I tried:
db.Epochs.find({
'ModelId': { '$oid': '624616797870316ac1432d52' }
}).sort({'End': -1})
Which errors with:
unknown operator: $oid

mongoose.connect() url argument must be of type string

I'm getting the following error when using mongoose.connect()
error: The "url" argument must be of type string. Received undefined {"data":{"code":"ERR_INVALID_ARG_TYPE"}}
I'm using it like this:
const mongoose = require("mongoose");
const url = process.env.MONGODB_URL;
mongoose.connect(url, {
useNewUrlParser: true,
});
I've also tried it without the environment variable:
const mongoose = require("mongoose");
mongoose.connect("mongodb+srv://username:password#myurl.com/etc", {
useNewUrlParser: true,
});
The stack trace looks like this:
43|api-dev | TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
43|api-dev | at validateString (internal/validators.js:124:11)
43|api-dev | at Url.parse (url.js:160:3)
43|api-dev | at Object.urlParse [as parse] (url.js:155:13)
43|api-dev | at dispatchHttpRequest (/var/www/api-dev/node_modules/axios/lib/adapters/http.js:91:22)
43|api-dev | at new Promise (<anonymous>)
43|api-dev | at httpAdapter (/var/www/api-dev/node_modules/axios/lib/adapters/http.js:46:10)
43|api-dev | at dispatchRequest (/var/www/api-dev/node_modules/axios/lib/core/dispatchRequest.js:52:10)
43|api-dev | at processTicksAndRejections (internal/process/task_queues.js:93:5)
It seems to be an axios error, but I'm not calling axios directly.
It works fine in my local environment, both with the env variable and the raw string, but not on my server. Ideas?
*The url string in this example has been replaced. I'm using the correct string in production.
The problem is because you forgot to add double quotations in your Mongoose connection string.
The answer should be:
const mongoose = require("mongoose");
mongoose.connect("mongodb+srv://username:password#myurl.com/etc", {
useNewUrlParser: true,
});
With the double quotes.
This turned out not to be about mongo.connect() at all, but was a typo in an env variable for another part of my program.

Using TNT4J, activity statistics are not coming properly

I want to log a activity which starts in the scope of a different class and ends in the scope of another class. Using TrackingLogger.getCurrentActivity() throws an exception as there is no activity in memory.Now if I try to store the activity in static HashMap in singleton Class and retrieve it in the other class, the snapshot of activity is showing confusing values. Here is what I am trying to do :
In first Class :
TrackingLogger tracker = TrackingLogger.getInstance(this.getClass()) ;
TrackingActivity activity = tracker.newActivity(); //
activity.start();
CacheUtil.addTrackingActivity("logger",activity); // Store it in static Hashmap in singleton class
In Second Class :
TrackingLogger tracker = TrackingLogger.getInstance(this.getClass());
TrackingActivity activity = CacheUtil.getTrackingActivity("logger");
activity.stop();
tracker.tnt(activity);
this is the snapshot generated :
18:37:39,780 INFO [Nastel TNT4J] {status: 'END' | time: '2014-07-30 13:07:39.778000 UTC' | sev: 'INFO' | type: 'ACTIVITY' | name: 'NOOP' | usec: '72827000' | wait.usec: '21000' | start.time: '2014-07-30 18:36:26.196000 IST' | end.time: '2014-07-30 18:37:39.023000 IST' | pid: '8092' | tid: '90' | id-count: '0' | snap-count: '6' | source: 'APPL=Nastel TNT4J#JVM=8092#FACH13140035#SERVER=FACH13140035#NETADDR=172.25.19.28#DATACENTER=default#GEOADDR=unknown' | track-id: '09d708c4-a6a9-4200-a70f-25c1da838c11'
Snapshot(CPU#Java) {
Count: 4
TotalCpuUsec: 46800.3
TotalCpuUserUsec: 46800.3
}
Snapshot(Thread#Java) {
Count: 69
DaemonCount: 46
StartedCount: 85
PeakCount: 69
BlockedCount: 7
WaitedCount: 0
BlockedUsec: 21000
WaitUsec: 0
}
Snapshot(Memory#Java) {
MaxBytes: 532742144
TotalBytes: 512499712
FreeBytes: 216341712
UsedBytes: 296158000
Usage: 57
}
Snapshot(Copy#GarbageCollector) {
Count: 477
Time: 1940
isValid: true
}
Snapshot(MarkSweepCompact#GarbageCollector) {
Count: 13
Time: 4652
isValid: true
}
Snapshot(Activity#Java) {
TotalCpuUsec: -1778411.4
SlackUsec: 74584411
WallUsec: -1757411.4
BlockedCount: -24
WaitedCount: -1
BlockedUsec: 21000
WaitUsec: 0
OverheadUsec: 24290.215
}}
Am I missing something?? Pls help ..
TrackingLogger.getCurrentActivity() will only return a valid activity if executed within the same thread. The activity handle is stored in thread local. so you most likely calling TrackingLogger.getCurrentActivity() from a different thread and therefore get an exception.
I am not exactly clear where the confusing values are. Can you elaborate?

Is it possible to pass a javascript function in the scope parameter of the Collection.map_reduce in pymongo?

Given:
jstrMap = """
function() {
print("isPointInside = " + isPointInside);
print("polygon = " + polygon);
emit(this._id, this);
}
"""
jstrReduce = """
function(key, values) {
return values[0];
}
"""
def readJSCodeFromFile(filePath):
with open(filePath) as f:
return Code(f.read())
jsIsPointInside = readJSCodeFromFile(path.join(path.dirname(__file__), 'IsPointInside.js'))
IsPointInside.js:
function(pt, poly) {
}
And I invoke map_reduce like this:
mycoll.map_reduce(jstrMap, jstrReduce, 'results',
scope = {'isPointInside': jsIsPointInside, 'polygon': [[-77, 39], [-77,38], [-78,38], [-78,39]]})
Here is what I get on the client console:
db assertion failure, assertion: 'map invoke failed: JS Error: TypeError: isPointInside is not a function nofile_b:3', assertionCode: 9014
And the server output is:
isPointInside = null
polygon = -77,39,-77,38,-78,38,-78,39
Sun Apr 01 16:29:14 [conn11] JS Error: TypeError: isPointInside is not a function nofile_b:3
Sun Apr 01 16:29:14 [conn11] mr failed, removing collection :: caused by :: 9014 map invoke failed: JS Error: TypeError: isPointInside is not a function nofile_b:3
Debugging the python code reveals that jsIsPointInside is of type Code, as expected. str(jsIsPointInside) returns the function text, i.e. 'function(pt, poly) {\n}\n'
I do not want to populate the system.js collection, I'd like to pass the function in the scope. Is it possible at all?
Thanks.
Scope is an object where the fields are placed in the MapReduce scope as variables w/ the field name.
If you'd like to put a function in scope, you need to make it a value a field e.g.
scope = {
myFunc: function() { return "Foo";}
}