facebook / memlab

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

devices is undefined when running memlabConfig.setDevice #126

Closed doteric closed 3 weeks ago

doteric commented 3 weeks ago

Hello šŸ‘‹

It looks like the memlabConfig.setDevice is no longer working after the puppeteer update.
Error:


    TypeError: Cannot read properties of undefined (reading 'iPhone 12')

      62 |   }
      63 |
    > 64 |   memlabConfig.setDevice(EMULATED_DEVICE_NAME, { manualOverride: true });
         |                ^
      65 |
      66 |   memlabConfig.puppeteerConfig.args = [
      67 |     ...(memlabConfig.puppeteerConfig.args || []),

      at MemLabConfig.setDevice (node_modules/@memlab/core/dist/lib/Config.js:555:21)
      at handler (src/main/index.ts:64:16)
      at Object.<anonymous> (src/main/index.test.ts:36:12)

It looks like the devices returns undefined here:

if (!devices[name]) { # <-- devices undefined here!
            const supportedDevices = Array.from(Object.keys(devices))
                .filter(name => isNaN(parseInt(name, 10)))
                .map(name => name.split(' ').join('-'));
            this.haltOrThrow(`Invalid device: ${name}`, () => {
                Console_1.default.lowLevel(`(supported devies: ${supportedDevices.join(', ')})`);
            });
        }

Seems like a breaking change

JacksonGL commented 3 weeks ago

I'll create a fix. Thanks for reporting this issue.

To quickly unblock yourself, replace .devices with .KnownDevices in the following code: https://github.com/facebook/memlab/blob/20f1e0f2df12808b8bd98ee406fbffe04d4daea8/packages/core/src/lib/Config.ts#L57