Netlify functions node16 support?

Hi,

I’m getting 502 bad gateway on a Netlify function with Unexpected token '??='.
Seems similar to

but from December functions have been nodejs14 by default and I also have optional chains in several other functions without problem. Function works fine locally.

here’s the function log

Mar 14, 01:21:08 PM: a2cf9476 2022-03-14T12:21:09.565Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '??='","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '??='","    at _loadUserApp (/var/runtime/UserFunction.js:200:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)","    at internal/main/run_main_module.js:17:47"]}
Mar 14, 01:21:08 PM: a2cf9476 2022-03-14T12:21:10.083Z	undefined	ERROR	Uncaught Exception 	{"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token '??='","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '??='","    at _loadUserApp (/var/runtime/UserFunction.js:200:13)","    at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)","    at Object.<anonymous> (/var/runtime/index.js:43:30)","    at Module._compile (internal/modules/cjs/loader.js:1085:14)","    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)","    at Module.load (internal/modules/cjs/loader.js:950:32)","    at Function.Module._load (internal/modules/cjs/loader.js:790:12)","    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)","    at internal/main/run_main_module.js:17:47"]}
Mar 14, 01:21:08 PM: a2cf9476 Unknown application error occurred
Mar 14, 01:21:08 PM: a2cf9476 Runtime.UserCodeSyntaxError
Mar 14, 01:21:09 PM: a2cf9476 Duration: 485.37 ms	Memory Usage: 31 MB

Has anybody had similar issues and know how to resolve it?

Turns out it had to do with a package that required node16 but node16 is yet to be supported by aws lambda.

Planned support of within 90 days of Feb 4th according to

Will Netlify functions then also automatically work with node16 or is there additional work that needs to happen first?

hey there @p.aarseth -

we have asked around a little bit for you and unfortunately, our hands are a little bit tied until AWS lambda catches up. This is a pain point for people - we are well aware and continuing to think on whether we can find another way to work on this. if changes happen, we will let you know as soon as we have something specific to share.

2 Likes

Any updates on this? I’m running into a very similar syntax error for ||=. It looks like AWS Lambda does support node16 now: Node.js 16.x runtime now available in AWS Lambda | AWS Compute Blog

This is the only thing preventing me from migrating from Vercel!

I think I figured it out! I followed this guide to set my lambda version to nodejs16.x: Optional configuration for functions | Netlify Docs

1 Like

Thanks for coming back and letting us know!