Developer Announcements

jmclaren
HubSpot Employee
HubSpot Employee

Deprecation of node v12 in all serverless functions

The original Developer Changelog announcement. The article content is copied from that post below for convenience. If you have questions or comments you can leave them below.


HubSpot has 3 areas where developers can build serverless functions. CMS Hub Serverless Functions, Workflow Custom Coded Actions, and Developer Projects, which is part of the CRM Development Tools beta. Node.js v12 reached it's end of life Apr 30, 2022. To ensure security we are deprecating support for Node.js v12 and automatically migrating where we can. We have multiple serverless function powered features so details for each are below.

For CMS Hub Serverless functions and Developer Projects: We encourage manually updating your functions and testing them with the newer node versions.

Custom Coded Workflow Actions

All NodeJS based custom coded actions have been upgraded and are currently running Node.js v16. There's no action required.

CMS Serverless Functions

We've released support for Node.js v18. You can now upgrade existing functions to Node.js v18.x in your serverless functions. You can also create new functions that use Node.js v18. You declare your Node version in the runtime property of your serverless.json file.

If you have not upgraded away from Node.js v12 by March 24th, 2023, your existing Node.js v12 functions will continue operating but you will be required to upgrade to a newer Node version to deploy changes to those functions.

We are unable to automatically detect whether your code is incompatible with the newer version of Node and convert it. Because of this we strongly recommend upgrading your functions ahead of March 24th to a newer version of Node.

Serverless Functions in Developer Projects

Serverless functions in Developer Projects support up to Node.js v16. You can now upgrade existing functions to Node.js v16 for functions in Developer Projects. You can also create new functions that use Node.js v16. You declare your Node version in the runtime property of your serverless.json file.

If you have not upgraded away from Node.js v12 by March 24th, 2023, your existing Node.js v12 functions will continue operating but you will be required to upgrade to a newer Node version to deploy changes to those functions.

We are unable to automatically detect whether your code is incompatible with the newer version of Node and convert it. Because of this, we strongly recommend upgrading your functions ahead of March 24th to a newer version of Node.

Package.json is now required

Previously, if your functions folder did not contain a packages.json, we provided a default set of packages developers could use. This included the HubSpot API Client. We're removing this "fallback" style functionality. While this was convenient for developers to get started, it complicates keeping packages and node versions up-to-date. Serverless function folders in Projects now require a package.json. This means developers will need to declare what packages they're actually using in order to use them in their function files.

Project builds will now throw an error when trying to upload a functions folder that does not contain a package.json. The CLI will communicate this error at build time, making it easier to identify this as the cause.

You can tell if you'll be impacted by this by reviewing your serverless function folder and confirming if there is currently a package.json file. If there is one, you're fine.

If you do not have one, you'll need to add one. You can identify what packages your functions are using by looking for any of the following lines in your function files (typically they would be at the top of your function file):

  • require('@hubspot/api-client');
  • require('axios');
  • require('request');
  • require('requests');

The default packages HubSpot provided if a packages.json file was not found were:

  • @hubspot/api-client: ^1.0.0-beta
  • axios: ^0.19.2
  • request: ^2.88.0
  • requests: ^0.2.2

Note: All of these are older versions of the packages. While you could declare the same version for a required package to get you by in the short term, we highly recommend upgrading to the latest version of your packages. Updating the version may require code changes, depending on the individual package.

Questions?

Please join us below.

Jon McLaren

Sr. CMS Developer Advocate

Get started developing on the HubSpot CMS Developer Changelog
How to optimize your CMS Hub site for speed

If my reply answered your question, please mark it as a solution, to make it easier for others to find.

1 Resposta 1
DianaGomez
Gerente da Comunidade
Gerente da Comunidade

Deprecation of node v12 in all serverless functions

Hi @jmclaren, hope you are doing well!

 

¡Thanks for sharing!

 

Best,

Diana


¿Sabías que la Comunidad está disponible en Español?
¡Participa hoy en conversaciones en el idioma de tu preferencia,cambiando el idioma en tus configuraciones!

Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !