Change function runtime node version

Hello,

This is also a major issue for us. I’ve also reported my concerns to the premium support and one of their product manager. They are aware of this limitation.

I’ve also created this feedback:

Please upvote

1 Like

Upvoted!

This is important. Using old Node v10 syntax and limitations is not good for productivity.

I’m mainly missing two things:

  • Optional chaining
  • Date with specified time zone as in new Date('2022-04-14 16:46:08 (CET)')

I was hoping that MongoDB 6.0 would bring an update to the Node engine, but no.

When can we expect an update?

Wow, this is disappointing. There should be a huge warning in the docs about how outdated node is for functions.

Fully agree. We have started moving away from functions except the super simple ones.

Have you changed your node version in atlas app services? If you did then please tell me that how can I update node version?

Hey everyone thanks for all the feedback! Our version of Node is actually custom so we are able to support some recent dependencies, it was based off of v10 but we are migrating to newer versions with the ability to support multiple ones as well.

Regarding syntax support I’d recommend to run your function with modern syntax, every function is transpiled so we are able to support newer ES features. If you have specific requests or have tried an npm package that doesn’t work please let me know and we will make sure to add support for it.

1 Like

Thank you @Gabriele_Cimato

I would like support for SAML. It requires Node v12 or later.

console.log(JSON.stringify(process.versions))  // {"node":"10.18.1"}

const saml = require('saml');  // {}

PS: When I read documentation at https://www.mongodb.com/docs/manual/core/server-side-javascript/ I had the impression that runtime was improved at 6.0:

MongoDB 6.0 upgrades the internal JavaScript engine used for server-side JavaScript, $accumulator, $function, and $where expressions and from MozJS-60 to MozJS-91.

Hey @Milosz_Kowalski I was able to use the “saml” package in functions, so I’d recommend to try doing what you wanted to do with saml and let me know if you have specific errors coming up. I don’t have valid saml options to test this out fully though. There’s also @node-saml/passport-saml which might also help as an alternative if you end up being blocked with what you want to accomplish now.

Regarding the link that’s the drivers doc not app services which doesn’t use a custom Node engine like we do for App Services Functions.

Well @Gabriele_Cimato, it’s the signing part that doesn’t work with saml package. I would be happy if this one can be supported!

Simple example:

I looked into this and it seems like something is being corrupted during transpilation. If you try to upload a compressed archive like so:

instead of installing the dependency I noticed that it works as expected. Give it a try to see if you can get unblocked while I keep investigating. I hope this helps!

Not really.

I uploaded a node_modules archive and dependencies was installed. However, trying to use the library yields “Cannot found module saml”. It looks to be installed but isn’t.

More in next reply…

Now, installing library as intended, it looks like this. Same 3.0.1 version. The library is available and usable. Except for the signed part… Try for yourself, I’m adding the code below.

exports = async function(){
  
  const saml = require('saml').Saml20; 

  const options = {
    cert: "-----BEGIN CERTIFICATE-----MIIDQTCCAiigAwIBAgIBADANBgkqhkiG9w0BAQ0FADA6MQswCQYDVQQGEwJ1czELMAkGA1UECAwCQ0ExDjAMBgNVBAoMBU1vbmdvMQ4wDAYDVQQDDAVyZWFsbTAeFw0yMzA1MTcxNjMyMzhaFw0yNDA1MTYxNjMyMzhaMDoxCzAJBgNVBAYTAnVzMQswCQYDVQQIDAJDQTEOMAwGA1UECgwFTW9uZ28xDjAMBgNVBAMMBXJlYWxtMIIBIzANBgkqhkiG9w0BAQEFAAOCARAAMIIBCwKCAQIA36ruOTlsZvICTs9ve0Wc0fUe32wxrFTcrd+Y7ykMgSF2Ykyl+PYFgHUF6WkgdEeXQ23PfCNa+kGQvXM7wY9bQqWUa0Aiac07iArU7XZQYiOFmbcUWSPaGiOeTRvFKRR86ecnA/Faog880KzAYRf5g4E99RVeii0FtQwoYhO4VawoPtAMb2UEZZq/ByUX6zguGsBAQhFBi6I8ifK47I5kLbsYosQNJrhiTSEyb6nHW//k7N7C8NlmHLfzz+2bRmq+zh29FznrwPN/i/pGVnKhElm2R/wvaR+YhpUzyfNX/5M7HgH8mlCNfFMFeh9kbhCUc745nsauhkSkJNVqsppqLoUCAwEAAaNQME4wHQYDVR0OBBYEFDW1+Br2+ROw7Fr1e1W6kv8KrW58MB8GA1UdIwQYMBaAFDW1+Br2+ROw7Fr1e1W6kv8KrW58MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQENBQADggECAEokh67pGDITXtx0f6H9D22LGNqqGsjHt+DHWk9Kjf7AY7i7qZ1yN5TyWRsrspWsJOfrTh/dOne1aHyHcLPPoY2aRzKaF7h0SV9QbjjURHKn4GlY7Xks3xQ4VxsxBTszUN8aqqLRuPcH3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JfUqweqzssPXY9M+1K4/+LQrxlBc5RFhXGCVqO+PevjitFDnPFXe+leOnj8L1eYtLXDSsSNAnAGqlRmS32LN8HYbAoGBDjk/H0tyQYmpKnGG93eKFxw5wjzKBlL3M54X1Xf1Y6pFu841jLjCUJ37kh3JAoHdc8Fx8140tu6mFZsMusbdwyivQ8tEUKvmnaOvrhQo41HErjbx/JEZu7MtSlr4o8s5S2PPNQktnacTwuj9njFsRbagOblvxYDQHzziwurE8rffAoGBDDuzwzdUTfaZ4rhUQjAJFunZPro+8YbBHcmt/R/OVAE54nwns+kwkTaQ1Zg/2Jb+yETvCWTrMyWZ+RYmur4suyrHYKRdt6xzW81zC7GjQq+nflf2bJ3gyCS7SPlU/a2xb+WgfmevV8HVyXXylyzB6J/kyLlMAhGpyuRiRjZvT6oRAoGBC8VOOny6OghNKWW39rVDXuqp1ddurJseHeZX/P1/4pG3kbsNz73aeNK0rO/fOCb2d+P/hBJS94w5f6nHeA442Vei6yydBVGs0In0SdA/Ihe59x5bVdNSg2W9Nkpgd1Qnvv8DK/XDfTMWBHfB4pct7ec7Y2nVWJHIKgG9+uZERETrAoGBDuWOSauuHAXMW77e/4HMLrVMP7IuaXjWqudp2SRtQ49FIhgcnltU9f8e1OPQSD5fQrAOKjH34u39vpuMn6mI/wsWI44X234e9DcVIkmD4+pgtMRP7fk9IEUh9uM0h91FJ3+y9sp/5JZnqNqdHFlPYnsW1ePCE/f94tF3wK8dlFo/-----END PRIVATE KEY-----",
    issuer: 'urn:issuer',
    lifetimeInSeconds: 600,
    audiences: 'urn:myapp',
    attributes: { 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress': 'foo@bar.com', 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name': 'Foo Bar' },
    nameIdentifier: 'foo',
    sessionIndex: '_faed468a-15a0-4668-aed6-3d9c478cc8fa'
  };
    
  return {
    signedAssertion: saml.create(options),
    assertion: saml.createUnsignedAssertion(options)
  };
}

Hey @Mikael_Gurenius I think I identified the issue, we’re currently working on it and I’m hoping to get a fix out before EOW. I will update you here once the fix is out!

@Mikael_Gurenius I just deployed a fix, would you mind giving it another try? No need to upload dependencies you should be able to do it by adding “SAML” through the UI. Just to be safe try it with a new app and let me know!

@Gabriele_Cimato, thank you! I can confirm that the code snippet I posted above is now working! :slight_smile:

What was the issue?

…but is awfully slow. :frowning:

Testing a few times is 1.5 - 2.0 seconds for the execution. Whereby my current implementation is stable in the 0.5 - 0.7 region doing an external HTTP call to a node server with one task: return the signedAssertion.

Is there anything to be done with the performance?

image

When you will update the current Node version from V10.18.1 to latest version??

1 Like

Hello Gabriele.
The mailgun.js package does not work because it requires a version 12 of node or higher.

Do you have any idea when a higher version will arrive?

1 Like

Hey all! We have several projects on functions underway and hope to have something very exciting to announce for you all in the upcoming year.

To shed some more light on the feedback item here, we maintain and run our own custom JS runtime. As part of that, there is a minimum compatibility guarantee of Node v10 APIs, but we have implemented support beyond v10 for various packages.

The product team would love to learn more and gather your feedback on this – take our survey! https://forms.gle/TrKfPyimNF7h6UGs5