Aphlict server will not start in nodejs 10


#1

Observed Behavior:
Aphlict notification server no longer starts

Expected Behavior:
Aphlict notification server should start

Phabricator Version:
phabricator
2e7686262637072e72fd713054102575ec601356 (Fri, Apr 27) (branched from 5f774f7008b48d22839ced7040fbe5b1d48c2d34 on origin)
arcanist
8794ce1eaca0b3ef020e2cd5d2d5479fd3626b9f (Fri, Apr 27) (branched from a604548101025875de20a9c263df3790fea425b3 on origin)
phutil
f3e10579f640ebad648c56f677164647ab7251a4 (Fri, Apr 13) (branched from 20eff1c8d14f08f05ef72828fa379e871d29662c on origin)
diff
3.6 at /bin/diff
git
2.17.0 at /bin/git
hg
Not Available
pygmentize
2.2.0 at /bin/pygmentize
svn
1.9.7 at /bin/svn

Reproduction Steps:
This occurred after updating nodejs and npm to version v10.0.0 (node) and 6.0.0 (npm) on archlinux (date being 2018-05-01). After the update aphlict would no longer start, getting a exception of:

May 01 10:30:53 phab aphlict[1811]: Reading configuration from: phabricator/conf/aphlict/aphlict.default.json
May 01 10:30:53 phab aphlict[1811]: [2018-05-01 10:30:53] EXCEPTION: (CommandException) Command failed with error #1!
May 01 10:30:53 phab aphlict[1811]: COMMAND
May 01 10:30:53 phab aphlict[1811]: node '--max-old-space-size=256' -- '/opt/phacility/phabricator/support/aphlict/server/aphlict_server.js' '--config=/opt/phacility/phabricator/conf/aphlict/aphlict.default.json' '--test=true'
May 01 10:30:53 phab aphlict[1811]: STDOUT
May 01 10:30:53 phab aphlict[1811]: (empty)
May 01 10:30:53 phab aphlict[1811]: STDERR
May 01 10:30:53 phab aphlict[1811]: vm.js:148
May 01 10:30:53 phab aphlict[1811]:     throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
May 01 10:30:53 phab aphlict[1811]:     ^
May 01 10:30:53 phab aphlict[1811]: TypeError [ERR_INVALID_ARG_TYPE]: The "options" argument must be of type Object. Received type string
May 01 10:30:53 phab aphlict[1811]:     at getRunInContextArgs (vm.js:148:11)
May 01 10:30:53 phab aphlict[1811]:     at Script.runInContext (vm.js:97:37)
May 01 10:30:53 phab aphlict[1811]:     at Script.runInNewContext (vm.js:108:17)
May 01 10:30:53 phab aphlict[1811]:     at Object.JX.require (/opt/phacility/phabricator/webroot/rsrc/externals/javelin/core/init_node.js:52:6)
May 01 10:30:53 phab aphlict[1811]:     at Object.<anonymous> (/opt/phacility/phabricator/support/aphlict/server/lib/javelin.js:4:4)
May 01 10:30:53 phab aphlict[1811]:     at Module._compile (internal/modules/cjs/loader.js:678:30)
May 01 10:30:53 phab aphlict[1811]:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
May 01 10:30:53 phab aphlict[1811]:     at Module.load (internal/modules/cjs/loader.js:589:32)
May 01 10:30:53 phab aphlict[1811]:     at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
May 01 10:30:53 phab aphlict[1811]:     at Function.Module._load (internal/modules/cjs/loader.js:520:3)
May 01 10:30:53 phab aphlict[1811]:  at [<phutil>/src/future/exec/ExecFuture.php:369]
May 01 10:30:53 phab aphlict[1811]: arcanist(head=stable, ref.master=5eda40337bb4, ref.stable=8794ce1eaca0), phabricator(head=stable, ref.master=df21391b8e7b, ref.stable=2e7686262637, custom=7), phutil(head=stable, ref.master=276f>
May 01 10:30:53 phab aphlict[1811]:   #0 ExecFuture::resolvex() called at [<phutil>/src/future/exec/execx.php:17]
May 01 10:30:53 phab aphlict[1811]:   #1 execx(string, PhutilCommandString) called at [<phabricator>/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php:377]
May 01 10:30:53 phab aphlict[1811]:   #2 PhabricatorAphlictManagementWorkflow::willLaunch() called at [<phabricator>/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php:442]
May 01 10:30:53 phab aphlict[1811]:   #3 PhabricatorAphlictManagementWorkflow::executeStartCommand() called at [<phabricator>/src/applications/aphlict/management/PhabricatorAphlictManagementStartWorkflow.php:15]
May 01 10:30:53 phab aphlict[1811]:   #4 PhabricatorAphlictManagementStartWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:441]
May 01 10:30:53 phab aphlict[1811]:   #5 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:333]
May 01 10:30:53 phab aphlict[1811]:   #6 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/support/aphlict/server/aphlict_launcher.php:23]

I was able to locally patch javelin:

diff --git a/webroot/rsrc/externals/javelin/core/init_node.js b/webroot/rsrc/externals/javelin/core/init_node.js
index 19834664b..97ae94e56 100644
--- a/webroot/rsrc/externals/javelin/core/init_node.js
+++ b/webroot/rsrc/externals/javelin/core/init_node.js
@@ -48,8 +48,7 @@ JX.require = function(thing) {
     sandbox[k] = extra[k];
   }
 
-  vm.createScript(content, path)
-    .runInNewContext(sandbox, path);
+  vm.runInNewContext(content, sandbox, path);
 };

this allowed the notification server to start again


Aphlict fails to start. Node cmd error
#2

I didn’t understand this answer and posted a question very similar. I was referenced to this post and they provided an explanation to how to perform this modification located here.

I’m bumping this older post since I think this is something that should be addressed. The latest NodeJS install for CentOS7 and the javelin files included in Phabricator do not work without modifying a couple lines of code. I don’t know how difficult it would be to fix in code, but a few lines added to the notification server instructions would mitigate this issue and take very little time.