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

😈 Fix disconnect promise race. #2359

Merged
merged 1 commit into from
May 25, 2017
Merged

😈 Fix disconnect promise race. #2359

merged 1 commit into from
May 25, 2017

Conversation

samccone
Copy link
Contributor

@samccone samccone commented May 25, 2017

It is possible that we were resolving the gather chain before we had
disconnected. When manually launching and killing chrome this can race
and result in an error to the user.

This fixes that problem. \o/.

Fixes #2337


Test plan:

Run launcher with:

const lighthouse = require('lighthouse');

import {launch} from './chrome-launcher';

async function runLighthouse(url: string) {
  const opts = {
    chromeFlags: ['--headless'],
  };
  const chrome = await launch(opts);
  const flags = {
    output: 'json',
    port: chrome.port,
  };

  const results = await lighthouse(url, flags);

  process.on('uncaughtException', (e: any) => {
    console.log(e);
  });

  await chrome.kill();
  return results;
}

runLighthouse('https://example.com');

Without this patch, and then run it with the patch. Observe it now working.

It is possible that we were resolving the gather chain before we had
disconnected. When manually launching and killing chrome this can race
and result in an error to the user.

This fixes that problem. \o/.

Fixes #2337

---

Test plan:

Run launcher with:

```ts
const lighthouse = require('lighthouse');

import {launch} from './chrome-launcher';

async function runLighthouse(url: string) {
  const opts = {
    chromeFlags: ['--headless'],
  };
  const chrome = await launch(opts);
  const flags = {
    output: 'json',
    port: chrome.port,
  };

  const results = await lighthouse(url, flags);

  process.on('uncaughtException', (e: any) => {
    console.log(e);
  });

  await chrome.kill();
  return results;
}

runLighthouse('https://example.com');
```

Without this patch, and then run it with the patch. Observe it now
working.
Copy link
Contributor

@ebidel ebidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified!

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was inevitable :) I was occasionally seeing the same error while running plots (no headless) on Linux

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

Successfully merging this pull request may close these issues.

Chromelauncher error on when killing instance
3 participants