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

setup callback is not called even if provided #25

Closed wolasss closed 1 year ago

wolasss commented 1 year ago

According to the documentation if you provide setup function it will be called before action callback is executed.

It does not seem to be working, consider the following example:

test.js:

function url() {
    return 'http://127.0.0.1:3000';
}

async function setup(page) {
    console.log('setup');
    throw new Error('setup');
}

async function action(page) {
    console.log('action');
    throw new Error('action');
}

async function back(page) {
    throw new Error('back');
}

module.exports = { action, back, setup, url };

executed with memlab run --headful --scenario test.js

result:

page-load[11.4MB](baseline)[s1] > action-on-page(target)[s2] > revert(final)[s3]
action
page-load[11.4MB](baseline)[s1] > action-on-page(target)[s2] > revert(final)[s3]
Use `memlab help` or `memlab <COMMAND> -h` to get helper text
interaction fail

as you can see, the setup callback was never called.

memlab version:

 memlab@1.1.27
 @memlab/heap-analysis@1.0.9
 @memlab/e2e@1.0.11
 @memlab/core@1.1.10
 @memlab/cli@1.0.12
 @memlab/api@1.0.11
JacksonGL commented 1 year ago

@wolasss Thanks for the reporting this. Just published a new npm version that contains the setup callback. Please use @memlab/e2e@1.0.12. Let me know if it doesn't work.

$ memlab version

 memlab@1.1.28
 @memlab/heap-analysis@1.0.9
 @memlab/e2e@1.0.12
 @memlab/core@1.1.10
 @memlab/cli@1.0.14
 @memlab/api@1.0.11
wolasss commented 1 year ago

@JacksonGL

for some reason, after the upgrade I can't run find-leaks anymore:

snapshot meta data invalid or missing
Use `memlab help` or `memlab <COMMAND> -h` to get helper text

I tried memlab reset, but it is still not working.

memlab version:

 memlab@1.1.28
 @memlab/heap-analysis@1.0.9
 @memlab/e2e@1.0.12
 @memlab/core@1.1.10
 @memlab/cli@1.0.14
 @memlab/api@1.0.11
JacksonGL commented 1 year ago

@wolasss can you rerun memlab run --scenario file.js before running find-leaks?

The working directory (use memlab get-default-work-dir to view) may have been changed after package upgrade

JacksonGL commented 1 year ago

memlab reset deletes all snapshot files from the previous memlab run, so memlab find-leaks cannot load the snapshot files anymore

wolasss commented 1 year ago

@wolasss can you rerun memlab run --scenario file.js before running find-leaks?

The working directory (use memlab get-default-work-dir to view) may have been changed after package upgrade

gotcha, my mistake. I meant to execute run command.

It does work now, thanks!