facebook / memlab

A framework for finding JavaScript memory leaks and analyzing heap snapshots
https://facebook.github.io/memlab/
MIT License
4.35k stars 118 forks source link

interaction fail error #58

Closed OnurGumus closed 1 year ago

OnurGumus commented 1 year ago

Hi, I am just follow the tutorial and even youtube one fails with below

page-load(baseline)[s1] > action-on-page(target)[s2] > revert(final)[s3]  
interaction fail, making 2 more attempt(s)...
interaction fail, making 1 more attempt(s)...
Use `memlab help` or `memlab <COMMAND> -h` to get helper text
interaction fail
onur@Onurs-MBP scenarios % 

Error seems cryptic and I don't understand what's wrong.

JacksonGL commented 1 year ago

@OnurGumus Thanks for reporting this issue. Are you following this tutorial?

I couldn't reproduce the error. Which version of OS and memlab are you using? (please check memlab versions with the memlab version command)

Can you add the --verbose flag when running memlab and copy-and-paste the error message here? Thanks

OnurGumus commented 1 year ago

@JacksonGL Yes I am following that tutorial.

 memlab version                  

 memlab@1.1.36
 @memlab/heap-analysis@1.0.17
 @memlab/e2e@1.0.20
 @memlab/core@1.1.19
 @memlab/cli@1.0.22
 @memlab/api@1.0.19
memlab run --verbose  --scenario  scenario.js
Xvfb supports: false
Xvfb: true
{
  "_browserVersion": "HeadlessChrome/101.0.4950.0",
  "_puppeteerConfig": {
    "headless": true,
    "devtools": false,
    "ignoreHTTPSErrors": true,
    "ignoreDefaultArgs": [
      "--disable-extensions"
    ],
    "userDataDir": "/var/folders/76/vmvg64r93q5dx65r5h6xrxw00000gn/T/memlab/data/profile",
    "args": [
      "--no-sandbox",
      "--disable-notifications",
      "--use-fake-ui-for-media-stream",
      "--use-fake-device-for-media-stream",
      "--js-flags=\"--no-move-object-start\"",
      "--enable-precise-memory-info",
      "browser-test"
    ],
    "defaultViewport": {
      "width": 1680,
      "height": 1080,
      "deviceScaleFactor": 1
    }
  },
  "_consoleMessages": []
}
Browser version: HeadlessChrome/101.0.4950.0
Node.js version: v18.12.1
Start tracking JS heap
Mon Jan 16 2023 14:22:31 GMT+0100 (Central European Standard Time)
[1/3] visiting page-load (baseline)
page-load(baseline)[s1] > action-on-page(target)[s2] > revert(final)[s3]  
url: https://www.youtube.com
loading: https://www.youtube.com
[console.error]: Failed to load resource: the server responded with a status of 403 ()
[console.info]: LegacyDataMixin will be applied to all legacy elements.
[console.info]: Set `_legacyUndefinedCheck: true` on element class to enable.
Error: Protocol error (Runtime.callFunctionOn): Session closed. Most likely the page has been closed.
    at CDPSession.send (/Users/onur/.nvm/versions/node/v18.12.1/lib/node_modules/memlab/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:218:35)
    at ExecutionContext._evaluateInternal (/Users/onur/.nvm/versions/node/v18.12.1/lib/node_modules/memlab/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:204:50)
    at ExecutionContext.evaluate (/Users/onur/.nvm/versions/node/v18.12.1/lib/node_modules/memlab/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:27)
    at DOMWorld.evaluate (/Users/onur/.nvm/versions/node/v18.12.1/lib/node_modules/memlab/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:97:24)
JacksonGL commented 1 year ago

[console.error]: Failed to load resource: the server responded with a status of 403 ()

It seems like there was a problem connecting to YouTube when the page first loaded (403 means the server refused to authorize the request). Not sure why this happens. You can try running memlab on a different machine or internet connection. Turning off your VPN or proxy server (if any) might also help.

Additionally, you can run the scenario in "headful" mode by adding the flags --debug --headful. This will open Chromium and pause the memlab execution, allowing you to manually type in the YouTube url and check for any browser or network issues.

JacksonGL commented 1 year ago

Closing as the error is not reproducible

Ni55aN commented 1 year ago

The example from the main page throws exactly the same error

// test.js
function url() {
  return 'https://www.google.com/maps/';
}
async function action(page) {
  await page.click('button[aria-label="Hotels"]');
}
async function back(page) {
  await page.click('[aria-label="Clear search"]');
}

module.exports = {action, back, url};
JacksonGL commented 1 year ago

@Ni55aN The reason for the error in that specific example is the UI element specified in the test scenario file can not be found in the page. I need to find a better example to showcase on the main page.

Try this test scenarios which pins to a location, let me know if this still doesn't work:

// test.js
function url() {
  return 'https://www.google.com/maps/place/Silicon+Valley,+CA/@37.4026892,-122.2059062,11z';
}
async function action(page) {
  await page.click('button[aria-label="Hotels"]');
}
async function back(page) {
  await page.click('[aria-label="Clear search"]');
}

module.exports = {action, back, url};
Ni55aN commented 1 year ago

@JacksonGL yep, the examples from docs work fine