steveszc / ember-cli-memory-leak-detector

Automatic memory leak detection for ember apps
https://www.npmjs.com/package/ember-cli-memory-leak-detector
MIT License
38 stars 5 forks source link

Unable to connect to chrome error (ember exam --parallel) #40

Closed joshuaswift closed 3 years ago

joshuaswift commented 3 years ago

Hi! Just installed this addon in our app but we currently get this error after we run tests every time. This happens if we run the tests locally or on our CI.

Any ideas what could be causing it?

Thanks!

image

This is our test script: "test": "percy exec -t 250 -- ember exam --random=10 --split=16 --parallel",

This is our testem config:

/* eslint-env node */
module.exports = {
  framework: 'qunit',
  test_page: 'tests/index.html?hidepassed',
  disable_watching: true,
  reporter: Reporters,
  report_file: './reports/test-results.xml',
  xunit_intermediate_output: true,
  launch_in_ci: ['Chrome'],
  launch_in_dev: ['Chrome'],
  browser_start_timeout: 10,
  socket_heartbeat_timeout: 10,
  browser_disconnect_timeout: 10,
  browser_reconnect_limit: 10,
  parallel: 16,
  browser_args: {
    Chrome: {
      dev: ['--remote-debugging-port=9222'],
      ci: [
        '--disable-dev-shm-usage',
        '--disable-gpu',
        '--disable-software-rasterizer',
        '--disable-web-security',
        '--headless',
        '--incognito',
        '--mute-audio',
        '--no-sandbox',
        '--remote-debugging-address=0.0.0.0',
        '--remote-debugging-port=9222',
      ],
    },
  },
};
steveszc commented 3 years ago

Your remote-debugging-address flag looks suspicious. I haven't seen that before and haven't tested the addon with that flag present. I would try removing that.

The error you got indicates that we connencted to a chrome instance over port 9222, but there were no tabs running in that instance. Is it possible you have multiple instances of chrome running with a remote debugging port?

steveszc commented 3 years ago

Also, have you tried running with a simpler ember test or ember test --server to see if the same issue occurs? I'm especially curious about ember test --server since that will use the dev browser args in your testem config instead of the ci args.

steveszc commented 3 years ago

It very well could be an issue with ember exam's parallel flag. I assume the parallel arg will cause testem to boot up multiple chrome instances all running on the same remote debugging port. When the addon attempts to connect to chrome to capture a heap snapshot, it will just be luck-of-the-draw deciding which chrome instance we actually connect to.

In order for this to work properly we need to make sure that every instance of chrome is running on a unique debugging port which would take some coordination between the addon config, the testem config, and ember exam. This is going to be tricky to solve, and nothing is coming to mind immediately.

cjsissingh commented 3 years ago

I have the same problem using ember test and ember test --serve.

I installed ember-cli-memory-leak a few months ago and it worked fine. Tried again today (after your ember-conf talk) and starting to see this error. I have tried to install older version 0.5.0 and got the same result, so I'm not convinced it's anything you've changed. I'm just not sure where to look next.

ember-cli-memory-leak-detector: Error: Unable to connect to chrome. Error: Tab titled "✔ ReconzUser Tests (338/338)" did not match any of: "✖ ReconzUser Tests (936/937)"

The "did not match any..." name doesn't appear to change even after applying a --filter like I did to get the error above.

joshuaswift commented 3 years ago

@steveszc I tried removing remote-debugging-address flag and running ember test --serve but same error unfortunately. Running the tests in parallel does seem like it would cause problems but weird that it still happens with the regular ember test command.

steveszc commented 3 years ago

The did not match any of: part of the error lists all the tab titles found in the chrome instance we connected to. So this is indicating that we have successfully connected to chrome over the remote debugging port, but we're not seeing the tab that is actually running our tests. This indicates that there are multiple instances of Chrome running with the same remote debugging port open, and we happened to connect to the wrong instance. This could be true of both case, either when there is a mismatched title or no title.

It's possible that there is a headless instance of chrome "invisibly" hanging around after one of these unsuccessful attempts. I remember running into a similar issue a few times while I was building the addon. You could try restarting your machine, or kill all chrome instances in your process manager, and then try again.

cjsissingh commented 3 years ago

You could try restarting your machine, or kill all chrome instances in your process manager, and then try again.

This worked for me. Thanks @steveszc!

joshuaswift commented 3 years ago

You could try restarting your machine, or kill all chrome instances in your process manager, and then try again.

This worked for me. Thanks @steveszc!

This also worked for me locally, thanks!