Homey Pro (Early 2023) is now available in Early Access
Developer's update: Node.js version 12 LTS

Developer's update: Node.js version 12 LTS

With the release of Homey v4.2.0 we are going to update Homey to use Node.js version 12. This is the latest LTS release which ensures we can stay up to date with bug fixes and security patches.

This shouldn't impact you, but Node.js has become somewhat stricter in it's code parsing since version 12. Therefore you might see code crashes that weren't there before.

Early syntax errors

One potential issue we have already noticed is that certain SyntaxErrors are now detected even when code is not executed. Specifically the following piece of code used to work in Node.js version 8 (as long as the function or method is not called) but will throw a syntax error in Node.js version 12:

function hello(name) {
  const { name } = {}; // SyntaxError: Identifier 'name' has already been declared
}
 

In order to catch errors like these, we recommend you to use ESLint (view our ESLint config).

Node.js Deprecations

For your convenience we collected a list of all the API deprecations between Node.js version 8 and Node.js version 12, you can find more details on these changes in the Deprecated APIs page on the Node.js docs https://nodejs.org/docs/latest-v12.x/api/deprecations.html:

  • DEP0004: CryptoStream.prototype.readyState
  • DEP0006: child_process options.customFds
  • DEP0007: Replace cluster worker.suicide with worker.exitedAfterDisconnect
  • DEP0010: crypto.createCredentials
  • DEP0011: crypto.Credentials
  • DEP0012: Domain.dispose
  • DEP0013: fs asynchronous function without callback
  • DEP0017: Intl.v8BreakIterator
  • DEP0019: require('.') resolved outside directory
  • DEP0021: Server.listenFD
  • DEP0023: os.getNetworkInterfaces()
  • DEP0024: REPLServer.prototype.convertToContext()
  • DEP0026: util.print()
  • DEP0027: util.puts()
  • DEP0028: util.debug()
  • DEP0029: util.error()
  • DEP0041: NODE_REPL_HISTORY_FILE environment variable
  • DEP0042: tls.CryptoStream
  • DEP0061: fs.SyncWriteStream
  • DEP0062: node --debug
  • DEP0065: repl.REPL_MODE_MAGIC and NODE_REPL_MODE=magic
  • DEP0069: vm.runInDebugContext(string)
  • DEP0070: async_hooks.currentId()
  • DEP0071: async_hooks.triggerId()
  • DEP0072: async_hooks.AsyncResource.triggerId()
  • DEP0073: Several internal properties of net.Server
  • DEP0079: Custom inspection function on Objects via .inspect()
  • DEP0083: Disabling TLS ECDH by setting ecdhCurve to false
  • DEP0084: requiring bundled internal dependencies
  • DEP0085: AsyncHooks Sensitive API
  • DEP0086: Remove runInAsyncIdScope
  • DEP0090: Invalid GCM authentication tag lengths
  • DEP0098: AsyncHooks Embedder AsyncResource.emitBefore and AsyncResource.emitAfter APIs
  • DEP0099: async context-unaware node::MakeCallback C++ APIs
  • DEP0101: --with-lttng
  • DEP0102: Using noAssert in Buffer#(read|write) operations.
  • DEP0105: decipher.finaltol
  • DEP0107: tls.convertNPNProtocols()
  • DEP0114: crypto._toBuf()
  • DEP0117: Native crypto handles

In general your apps should continue to work without changes but we would like to ask you to verify this by joining our Experimental channel and running your apps on the latest pre-release version of Homey.

Suggestions

When you are taking a look at your code to verify it continues to work under Node.js version 12 we strongly suggest you also check whether you are using strict mode, catching promise rejections and using the new buffer constructor apis.

Strict mode

We recommend using strict mode in all your JavaScript files, not only does it make your code faster (in certain cases) is will also make it easier to write “secure” and correct code. Read more about how strict mode works here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode

Catching Promise rejections

Future versions of Node.js are likely to crash on unhandled promise rejections so it is very important that you make sure every promise has a “catch”-er. To help you with this we offer the this.error method on Homey.App Homey.Driver and Homey.Device. Using this method catching a promise is as easy as .catch(this.error).

New buffer constructors

In short: new Buffer() has been deprecated since Node.js version 6 due to security concerns, since it is widely used in the ecosystem it hasn’t been removed yet but it might be in the future. Please update your code to use Buffer.from() or Buffer.alloc() instead. Read more about porting to the new buffer constructors here: https://nodejs.org/fr/docs/guides/buffer-constructor-deprecation/

Be the first to hear about Homey’s latest developments.

Subscribe to our newsletter and stay up-to-date on new Homey features, exclusive offers and more.