[DAEMON-268] appcd-util: Add support for Node.js 11
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Resolved |
| Resolution | Fixed |
| Resolution Date | 2018-12-14T15:49:13.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Appc Daemon 2.0.0 |
| Components | appcd-core, appcd-util |
| Labels | n/a |
| Reporter | Chris Barber |
| Assignee | Chris Barber |
| Created | 2018-11-30T17:33:10.000+0000 |
| Updated | 2018-12-14T15:49:13.000+0000 |
Description
In Node.js 11, they've removed
timer_wrap which we use in appcd-util to get the Timer prototype and detect active timers.
Node.js 11 has also deprecated process.binding() (https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V11.md#notable-changes-3), so we won't be able to get fs_event_wrap to get a ref to the FSEvent prototype.
It's probably also a matter of time before process._getActiveHandles() is removed too.
A potential solution is to use [async hooks](https://nodejs.org/api/async_hooks.html) (introduced in Node.js 8.1.0). However, since async hooks must be explicitly enabled, we need to API.
This ticket proposes a new class HandleWatcher that lives in appcd-util. It would use async hooks as well as process._getActiveHandles() when either are available. This class would be created by the appcd-core Server instance and facilitate the closing of any open handles.
The appcd-util function getActiveHandles() will likely need to be deprecated.
Note that since the core process runs as Node.js 10.13.0, we have some time to figure this out.
Also, Node.js 11 changed setImmediate() and caused tailgate() to not work correctly. Simply need to stop forcing asynchronous execution of the tailgate callback.
https://github.com/appcelerator/appc-daemon/pull/347
It's also worth noting this is preventing the AMPLIFY CLI from supporting Node.js 11.