Question

Error Connecting managed mongodb from functions in nodejs runtime

I had been developing functions for use as a back end for a livechat I built, and when I first started development on it all, I had no issues connecting to my mongodb managed cluster on my DO account where I am also deploying the functions (to both dev namespaces and to an app platform app).

However, sometime on one day around 2 weeks ago now, there suddenly started to be an error with connecting to the mongodb cluster when using mongodb+srv:// to connect in the connection string.

This error was first noticed the day I went to deploy my functions to production under my app platform app, so at first I thought it was an issue with running them from inside the app platform. Then, I went to test and run the functions I had deployed to the dev namespace to see if those were running fine still, and those all had the same error in establishing a connection to the managed mongodb cluster using mongodb+srv:// even the functions which I had not updated or deployed again for several days and had been working when they were first deployed suffered this issue.

The error I get, and that still happens today anytime I try to connect to the managed mongodb cluster on DO, is related to an issue with grabbing the TXT records on the domain of the mongodb cluster and reading options from them. The way nodejs mongodb package does this is by first looking up to see if TXT records exist, and then if they are found on the domain, it then runs dns.resolve to pull the value of them and then read it to apply any options found in them.

However, the functions now all seem to have an issue running this dns.resolve and do not successfully pull the value of the TXT record found on the domain. So, the functions fail critically upon trying to run a .join('') on the result of this attempted grab of the value.

Activation Id: 0a4db821390a4e8a8db821390aee8a70
2022-10-03T09:58:28.69324308Z  stderr: /tmp/xdOM0hgE/node_modules/mongodb/lib/connection_string.js:83
2022-10-03T09:58:28.693292997Z stderr:                 const txtRecordOptions = new url_1.URLSearchParams(record[0].join(''));
2022-10-03T09:58:28.693298138Z stderr:                                                                              ^
2022-10-03T09:58:28.693301971Z stderr: 
2022-10-03T09:58:28.693305439Z stderr: TypeError: Cannot read property 'join' of undefined
2022-10-03T09:58:28.693309056Z stderr:     at QueryReqWrap.callback (/tmp/xdOM0hgE/node_modules/mongodb/lib/connection_string.js:83:78)
2022-10-03T09:58:28.693312715Z stderr:     at QueryReqWrap.onresolve [as oncomplete] (dns.js:212:10)
2022-10-03T09:58:28.704852Z    stderr: The action did not initialize or run as expected. Log data might be missing.

That is the full execution log from the function test console that I have just run again minutes ago (in order to see if this error was still persisting).

If this could be fixed, and I could be assured the error would not happen again, it would be amazing. Due to this error, I have had to set up and run mongodb on a droplet myself in order to be able to actually connect to it using just mongodb:// since this work requiring the functions (and a mongo connection from them) needed to go live into production and I could not use the managed mongo due to this error. Of course, I would vastly prefer to be able to use a managed mongodb, but that’s not an option from DO since I had not found any way to connect to them with just mongodb:// and the mongodb+srv:// is fatalling erroring.

Is there any way to open a ticket or something to have DO devs look into and fix this issue? I had hoped it would be discovered and corrected by now, but it seems that is not the case.

Please let me know any further steps I could take which might get this error solved ASAP!

Best, Jon.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Is there anyone from DigitalOcean that can respond to this issue? I’ve had colleagues and friends test this issue and successfully reproduce it as well, and I believe this is caused by some bug with the functions themselves and how they are deployed in containers by DO.

This issue did not occur prior to a few weeks ago, and my initial work developing with the functions were able to successfully connect to managed mongodb on DO using mongodb+srv:// connection strings. Then, starting a few weeks back, this error started to prevent functions (deployed within app platform or on namespaces for development) from successfully being able to connect to managed mongodb using mongodb+srv:// connection strings.

In the meantime, I have been using a droplet to host mongodb for my needs from the functions, and they are able to connect successfully using mongodb:// connection strings. However, I’d like to get back onto managed mongodb ASAP.

Is there any reliable hostname that may be used to connect to managed mongodb on DO using mongodb:// connection strings while this error persists with using mongodb+srv:// strings?

Also, where would be the place to submit this issue as a ticket to get it escalated to the proper people at DO for internal reproduction of it and future resolution?

Best, Jon.