Queued NodeJS Server-Side Script not working


#1

Hi guys,

I created a NodeJS Server-Side Script which get’s queued on POSTing to an API endpoint.
If I run through the queue with php artisan queue:work --queue=NAMEOFTHEQUEUE, the job doesn’t get executed.
The following error appears in the log after starting the worker:

[2017-02-16 19:37:09] local.ERROR: ErrorException: Undefined index: SERVER_PORT in /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/dreamfactory/df-script/src/Engines/NodeJs.php:56
Stack trace:
#0 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/dreamfactory/df-script/src/Engines/NodeJs.php(56): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined index...', '/opt/dreamfacto...', 56, Array)
#1 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/dreamfactory/df-script/src/Engines/ExecutedEngine.php(45): DreamFactory\Core\Script\Engines\NodeJs->enrobeScript('\n//For logging\n...', Array, Array)
#2 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/dreamfactory/df-script/src/Components/BaseEngineAdapter.php(133): DreamFactory\Core\Script\Engines\ExecutedEngine->executeString('\n//For logging\n...', 'service.fitbita...', Array, Array)
#3 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/dreamfactory/df-script/src/Components/ScriptHandler.php(32): DreamFactory\Core\Script\Components\BaseEngineAdapter->runScript('\n//For logging\n...', 'service.fitbita...', Array, Array, NULL)
#4 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/dreamfactory/df-script/src/Jobs/ScriptServiceJob.php(65): DreamFactory\Core\Script\Jobs\ScriptJob->handleScript('service.fitbita...', '\n//For logging\n...', 'nodejs', Array, Array, true)
#5 [internal function]: DreamFactory\Core\Script\Jobs\ScriptServiceJob->handle()
#6 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(1257): call_user_func_array(Array, Array)
#7 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9874): Illuminate\Container\Container->call(Array)
#8 [internal function]: Illuminate\Bus\Dispatcher->Illuminate\Bus\{closure}(Object(DreamFactory\Core\Script\Jobs\ScriptServiceJob))
#9 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9970): call_user_func(Object(Closure), Object(DreamFactory\Core\Script\Jobs\ScriptServiceJob))
#10 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(DreamFactory\Core\Script\Jobs\ScriptServiceJob))
#11 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9948): call_user_func(Object(Closure), Object(DreamFactory\Core\Script\Jobs\ScriptServiceJob))
#12 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(9875): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#13 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(41): Illuminate\Bus\Dispatcher->dispatchNow(Object(DreamFactory\Core\Script\Jobs\ScriptServiceJob))
#14 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(130): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\DatabaseJob), Array)
#15 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Queue/Jobs/DatabaseJob.php(49): Illuminate\Queue\Jobs\Job->resolveAndFire(Array)
#16 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(213): Illuminate\Queue\Jobs\DatabaseJob->fire()
#17 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(156): Illuminate\Queue\Worker->process('database', Object(Illuminate\Queue\Jobs\DatabaseJob), 0, 0)
#18 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(125): Illuminate\Queue\Worker->pop(NULL, 'fitbitactivityh...', 0, 3, 0)
#19 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(78): Illuminate\Queue\Console\WorkCommand->runWorker(NULL, 'fitbitactivityh...', 0, 128, false)
#20 [internal function]: Illuminate\Queue\Console\WorkCommand->fire()
#21 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/bootstrap/cache/compiled.php(1257): call_user_func_array(Array, Array)
#22 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Console/Command.php(169): Illuminate\Container\Container->call(Array)
#23 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/symfony/console/Command/Command.php(256): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/symfony/console/Application.php(794): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/symfony/console/Application.php(186): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /opt/dreamfactory-2.4.2-0/apps/dreamfactory/htdocs/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 {main}  

If I fire the script directly uppon API call without queu’ing it, it works, so it must have something to do with the queue.

Any ideas on this?


#2

No suggestions on that?

As I tried that with a fresh set up instance, could that be a bug?


#3

I guess I found the problem.
Opened an issue on GIthub.

Github Issue