Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

connectToChrome doesn't set this.chromeInstance #159

Closed
torbs opened this issue Aug 3, 2017 · 4 comments
Closed

connectToChrome doesn't set this.chromeInstance #159

torbs opened this issue Aug 3, 2017 · 4 comments
Milestone

Comments

@torbs
Copy link
Contributor

torbs commented Aug 3, 2017

I'm using chrome-launcher to run a headless chrome locally.

const chromeBrowser = chromeLauncher.launch({
    startingUrl: 'about:blank',
    chromeFlags: ['--headless'],
    port: 9222,
    logLevel: 'info',
});

chromeBrowser.then((chrome) => {
    const chromeless = new Chromeless({
        launchChrome: false,
        cdp: {
            port: chrome.port,
            host: 'localhost',
        },
    });
})

This gives av unhandledRejection error.
Catching the error I find that the error is at dist/src/chrome/local.js line 123 and thatLocalChrome.chromeInstance is undefined.

@adieuadieu
Copy link
Collaborator

adieuadieu commented Aug 3, 2017

Hi @torbs — could you share the stack trace of the caught unhandledRejection?

@torbs
Copy link
Contributor Author

torbs commented Aug 3, 2017

const port = this.chromeInstance ? this.chromeInstance.port : 9222
This test is not a part of the transpiled file. I would suggest getting the port from the options.cdp object instead.
I "fixed" this in the transpiled file:
Line 123: return [4 /*yield*/, CDP.Version({ port: this.options.cdp.port })];

@torbs
Copy link
Contributor Author

torbs commented Aug 3, 2017

@adieuadieu

TypeError: Cannot read property 'port' of undefined
    at LocalChrome.<anonymous> (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:124:85)
    at step (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:32:23)
    at Object.next (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:13:53)
    at /Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:7:71
    at __awaiter (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:3:12)
    at LocalChrome.setViewport (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:112:16)
    at LocalChrome.<anonymous> (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:102:51)
    at step (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:32:23)
    at Object.next (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:13:53)
    at fulfilled (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:4:58)
    at process._tickDomainCallback (internal/process/next_tick.js:129:7)
Promise {
  <rejected> TypeError: Cannot read property 'port' of undefined
    at LocalChrome.<anonymous> (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:124:85)
    at step (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:32:23)
    at Object.next (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:13:53)
    at /Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:7:71
    at __awaiter (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:3:12)
    at LocalChrome.setViewport (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:112:16)
    at LocalChrome.<anonymous> (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:102:51)
    at step (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:32:23)
    at Object.next (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:13:53)
    at fulfilled (/Users/xxx/projects/xxx/node_modules/chromeless/dist/src/chrome/local.js:4:58)
    at process._tickDomainCallback (internal/process/next_tick.js:129:7) }

@adieuadieu
Copy link
Collaborator

Hi @torbs thanks for reporting this and raising the PR to address it. I see what you mean: if Chromeless didn't launch Chrome, we won't have a chromeInstance, therefore no port.

@adieuadieu adieuadieu added this to the v1.2 milestone Aug 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants