Need a special offer?Find out if your project fits.
+

Cannot read property "fields" of undefined

Answered
Younus M asked on October 7, 2022

Hi,
 
While using the FM mongo connector, we are getting this error where it cannot read fields of undefined. The line its breaking on this line in "/app/node_modules/flexmonster-mongo-connector/build/query/builder/ProjectionQueryBuilder.js:58:46"

const schemaValueObject = schema.fields.get(fieldObject.uniqueName);

 
Which is from the FM mongo connector code. In this scenario schema is undefined, any reason why that might be? Its also intermittent, so doesn't always happen. Is there something more we would need to do besides what the guide says?
 
Thanks,
Younus

9 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster October 10, 2022

Hello,

Thank you for your question. 

Could you please give us some additional details regarding the issue? We would like to know if you have seen error messages on the Flexmonster pop-up or in the browser's console. Also, we suggest enabling the logs in your connector through the ConfigInterface object to see on which step the issue occurs: https://www.flexmonster.com/doc/configuring-mongodb-connector/ 

Looking forward to hearing from you.

Best Regards,
Maksym

Public
Younus M October 11, 2022

Hi,
Im seeing the error on the FE but it is also logged in the node server. And I do have logs enabled, thats how I was able to find where in flexmonsters code it was breaking.
 
Younus

Public
Maksym Diachenko Maksym Diachenko Flexmonster October 12, 2022

Hello, Younus!

Thank you for your feedback.
Our team reproduced a similar issue while expanding the fields after restarting the server. It is possible that this happened because different requests are trying to use the cached schema while the cache is cleared after the server restarts. We will fix this issue by updating the flexmonster-mongo-connector package in a future minor release, ETA November 1st. 
Feel free to contact us if any other questions arise.

Best Regards,
Maksym

Public
Younus M October 12, 2022

Hi Maksym,
 
Is this something we can get done sooner since its part of a minor release? This is affecting our work in production
 
Younus

Public
Maksym Diachenko Maksym Diachenko Flexmonster October 14, 2022

Hello, Younus! 

Thank you for the reply.

If you need to solve the issue faster than the provided ETA, you can modify the source code inside the /node_modules/flexmonster-mongo-connector/build/api/MongoAPIManager.js file. We recommend adding the getSchema method at the beginning of getSelectResult and getMembers methods:

getMembers(dbo, index, fieldObject, pagingObject) {
return __awaiter(this, void 0, void 0, function* () {
    yield this.getSchema(dbo, index);
//Other code is not changed
}

getSelectResult(dbo, index, query, pagingObject) {
return __awaiter(this, void 0, void 0, function* () {
    yield this.getSchema(dbo, index);
  //Other code is not changed
}

With this change, all the requests done by MongoDB Connector will resend the schema request if the schema is not present in the cache. 
Please let us know if this solution worked for you.

Best Regards,
Maksym

Public
Younus M October 14, 2022

Awesome, thanks! Ill let you know how it goes

Public
Younus M November 3, 2022

Hi, we're running into this again but its failing somewhere else. The patch seemed to have taken care of the other one so hoping we can do the same here.

TypeError: Cannot read property 'data' of null

on these lines (/flexmonster-mongo-connector/build/cache/DataManager.js:39:78):
Line 38: constregisterItem=this._requestsRegister.deleteItem(currentPage.pageToken);
Line 39: constretrievalResult=yieldthis.getDataChunk(registerItem.data,registerItem.iterator);
 
Seems like the registerItem is undefined here for some reason. Any help would be greatly appreciated.
 
Thanks,
Younus
 

Public
Maksym Diachenko Maksym Diachenko Flexmonster November 4, 2022

Hello, Younus!

Thank you for reporting the issue.
Flexmonster MongoDB connector splits large "/select" responses on chunks. If the server with the connector is restarted during the data transferring process, the current state gets lost. Since the state is lost the connector cannot find the next data chunk. This could be the reason for such errors.
Our team is going to handle the exception, ETA Nov15th. The connector will inform the client side that the data loading error has occurred.
Please let us know if this solution works for you.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster November 15, 2022

Hello, Younus,

Hope you are doing well.
Our team is happy to announce that the issue with the undefined data page after the server restart was fixed. The fix is included in the 2.9.38 version of Flexmonster Mongo DB Connector: https://www.flexmonster.com/release-notes/version-2-9-38/ 

Please let us know if the fix works.

Best regards,
Maksym

Please login or Register to Submit Answer