Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting inspector on 127.0.0.1:9229 failed: unknown error #6

Open
1 of 3 tasks
subooom opened this issue Sep 12, 2023 · 1 comment
Open
1 of 3 tasks

Starting inspector on 127.0.0.1:9229 failed: unknown error #6

subooom opened this issue Sep 12, 2023 · 1 comment

Comments

@subooom
Copy link

subooom commented Sep 12, 2023

Describe the bug
Getting a Starting inspector on 127.0.0.1:9229 failed: unknown error

Reproducible example

    public function processHTML(Request $request)
    {
        $nodeExecutablePath = 'C:\Program Files\nodejs\node.exe'; // Replace with the actual path
        
        $htmlContent = $request->all()[0]; // gets the html of the requester

        $puppeteer = new Puppeteer([
            'executable_path' => $nodeExecutablePath,
            'debug' => true
        ]);
        $browser = $puppeteer->launch();

        $page = $browser->newPage();
        $page->setContent($htmlContent);

        // Run JavaScript code within the page
        $result = $page->evaluate(JsFunction::create('
            // Your JavaScript code here
            
            return {test: 23}
        '));

        $browser->close();

        // Process the result, which contains the output of your JavaScript code
        // You can return this result or further process it as needed

        return response()->json(['result' => $result]);
    }

Expected behavior
$result to be {test: 23}

Generated logs


Symfony\Component\Process\Exception\ProcessFailedException: The command ""C:\Program Files\nodejs\node.exe" --inspect "\vendor\zoon\rialto\src/node-process/serve.js" \vendor\zoon\puphpeteer\src\PuppeteerConnectionDelegate.js "{""idle_timeout"":60,""log_node_console"":false,""log_browser_console"":false,""js_extra"":""""}"" failed.

Exit Code: 1(General error)

Working directory: \public

Output:
================


Error Output:
================
Starting inspector on 127.0.0.1:9229 failed: unknown error
{"__rialto_error__":true,"message":"listen UNKNOWN: unknown error 0.0.0.0","stack":"Error: listen UNKNOWN: unknown error 0.0.0.0\n    at Server.setupListenHandle [as _listen2] (node:net:1723:21)\n    at listenInCluster (node:net:1788:12)\n    at Server.listen (node:net:1876:7)\n    at C:\\Users\\subooom\\Projects\\upwork\\contract_1\\advend_api\\vendor\\zoon\\rialto\\src\\node-process\\Server.js:43:25\n    at new Promise (<anonymous>)\n    at Server.start (C:\\Users\\subooom\\Projects\\upwork\\contract_1\\advend_api\\vendor\\zoon\\rialto\\src\\node-process\\Server.js:42:16)\n    at new Server (C:\\Users\\subooom\\Projects\\upwork\\contract_1\\advend_api\\vendor\\zoon\\rialto\\src\\node-process\\Server.js:21:29)\n    at Object.<anonymous> (C:\\Users\\subooom\\Projects\\upwork\\contract_1\\advend_api\\vendor\\zoon\\rialto\\src\\node-process\\serve.js:37:16)\n    at Module._compile (node:internal/modules/cjs/loader:1254:14)\n    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)"} in file \vendor\zoon\rialto\src\ProcessSupervisor.php on line 309

#0 \vendor\zoon\rialto\src\ProcessSupervisor.php(344): Nesk\Rialto\ProcessSupervisor->checkProcessStatus()
#1 \vendor\zoon\rialto\src\ProcessSupervisor.php(149): Nesk\Rialto\ProcessSupervisor->serverPort()
#2 \vendor\zoon\rialto\src\AbstractEntryPoint.php(27): Nesk\Rialto\ProcessSupervisor->__construct('C:\\Users\\subooo...', Object(Nesk\Puphpeteer\PuppeteerProcessDelegate), Array)
#3 \vendor\zoon\puphpeteer\src\Puppeteer.php(79): Nesk\Rialto\AbstractEntryPoint->__construct('C:\\Users\\subooo...', Object(Nesk\Puphpeteer\PuppeteerProcessDelegate), Array, Array)
#4 \app\Http\Controllers\SnippetsController.php(123): Nesk\Puphpeteer\Puppeteer->__construct(Array)
#5 \vendor\laravel\framework\src\Illuminate\Routing\Controller.php(54): App\Http\Controllers\SnippetsController->processHTML(Object(Illuminate\Http\Request), '2a91657d35fc5ad...')
#6 \vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(43): Illuminate\Routing\Controller->callAction('processHTML', Array)
#7 \vendor\laravel\framework\src\Illuminate\Routing\Route.php(259): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\SnippetsController), 'processHTML')
#8 \vendor\laravel\framework\src\Illuminate\Routing\Route.php(205): Illuminate\Routing\Route->runController()
#9 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(798): Illuminate\Routing\Route->run()
#10 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(141): Illuminate\Routing\Router->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#11 \app\Http\Middleware\VerifyKey.php(23): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#12 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): App\Http\Middleware\VerifyKey->handle(Object(Illuminate\Http\Request), Object(Closure))
#13 \vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php(50): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#14 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#15 \vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(126): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#16 \vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(92): Illuminate\Routing\Middleware\ThrottleRequests->handleRequest(Object(Illuminate\Http\Request), Object(Closure), Array)
#17 \vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(54): Illuminate\Routing\Middleware\ThrottleRequests->handleRequestUsingNamedLimiter(Object(Illuminate\Http\Request), Object(Closure), 'api', Object(Closure))
#18 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Illuminate\Http\Request), Object(Closure), 'api')
#19 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#20 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(797): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#21 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(776): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#22 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(740): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))
#23 \vendor\laravel\framework\src\Illuminate\Routing\Router.php(729): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#24 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(200): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#25 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(141): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#26 \vendor\laravel\vapor-core\src\Http\Middleware\ServeStaticAssets.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#27 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Laravel\Vapor\Http\Middleware\ServeStaticAssets->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#29 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#30 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))
#31 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#32 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))
#33 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Illuminate\Foundation\Http\Middleware\TrimStrings->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#35 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illuminate\Http\Request), Object(Closure))
#36 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#37 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 \vendor\laravel\framework\src\Illuminate\Http\Middleware\HandleCors.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Illuminate\Http\Middleware\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))
#40 \vendor\laravel\framework\src\Illuminate\Http\Middleware\TrustProxies.php(39): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#41 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(180): Illuminate\Http\Middleware\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))
#42 \vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(116): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#43 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(175): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#44 \vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(144): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#45 \public\index.php(51): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#46 \vendor\laravel\framework\src\Illuminate\Foundation\resources\server.php(16): require_once('C:\\Users\\subooo...')
#47 {main}

Environment (please complete the following information):

  • OS: Windows 10
  • Node version: 18.15.0
  • PHP version 8.2.4

What I've done so far
netstat -ano | findstr :9229
returns TCP 127.0.0.1:54268 127.0.0.1:9229 SYN_SENT 6532
Get-Process -Id 6532
returns Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName 2308 70 197948 244980 210.34 6532 1 chrome

My Node package manager is:

  • NPM (specify the version)
  • Yarn (specify the version)
  • Other (specify the name and version)
@xtrime-ru
Copy link
Member

Hi!

I tried your example with minor changes (i use macos/linux), and there was no issues:

<?php

require __DIR__ . '/../vendor/autoload.php';

use Nesk\Puphpeteer\Puppeteer;
use Nesk\Rialto\Data\JsFunction;

$puppeteer = new Puppeteer([
    'executable_path' => 'node',
    'debug' => true
]);
$browser = $puppeteer->launch();

$page = $browser->newPage();
$page->setContent('');

// Run JavaScript code within the page
$result = $page->evaluate(JsFunction::createWithBody(/** @lang JavaScript */'    
    return {test: 23}
'));

printf('Result: %s', print_r($result, true));

$browser->close();
/opt/homebrew/bin/php /Users/xtrime/PhpstormProjects/zoon/puphpeteer/examples/03_execute_in_node.php
Result: Array
(
    [test] => 23
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants