docker-compose icon indicating copy to clipboard operation
docker-compose copied to clipboard

Cannot read property 'trim' of undefined when calling docker-compose ps -q

Open CherryDT opened this issue 4 years ago • 6 comments
trafficstars

Causing this issue downstream: https://github.com/input-output-hk/cardano-graphql/issues/552

TypeError: Cannot read property 'trim' of undefined
    at /home/ubuntu/.npm-global/lib/node_modules/@cardano-graphql/cli/node_modules/docker-compose/dist/index.js:73:38
    at Array.map (<anonymous>)
    at Object.mapPsOutput (/home/ubuntu/.npm-global/lib/node_modules/@cardano-graphql/cli/node_modules/docker-compose/dist/index.js:68:10)
    at Object.<anonymous> (/home/ubuntu/.npm-global/lib/node_modules/@cardano-graphql/cli/node_modules/docker-compose/dist/index.js:342:36)
    at step (/home/ubuntu/.npm-global/lib/node_modules/@cardano-graphql/cli/node_modules/docker-compose/dist/index.js:44:23)
    at Object.next (/home/ubuntu/.npm-global/lib/node_modules/@cardano-graphql/cli/node_modules/docker-compose/dist/index.js:25:53)
    at fulfilled (/home/ubuntu/.npm-global/lib/node_modules/@cardano-graphql/cli/node_modules/docker-compose/dist/index.js:16:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)

This happens when ps is called with -q because the output is just a list of hashes - single column, no headers - and your code seems to expect a certain table format in mapPsOutput.

CherryDT avatar Aug 07 '21 00:08 CherryDT

Highly possible that's how it would behave. Since we expect that we receive a "normal" output from the command, there is no error handling.

I guess we could both take care in cases where --quiet/-q option is passed, and if the output doesn't match what we expect.

Steveb-p avatar Aug 07 '21 15:08 Steveb-p

Yes, should be possible.

AlexZeitler avatar Aug 07 '21 19:08 AlexZeitler

@CherryDT Did #197 fix this for you?

AlexZeitler avatar Jan 15 '22 19:01 AlexZeitler

I'm not sure, since I had this happen to me only indirectly through @cardano-graphql/cli, and it seems they implemented some workaround on their end already because I used the command again a week ago (before your fix) and it worked flawlessly...

EDIT: I just realized I myself had opened a PR that fixed it downstream by pinning the dependency version... But, I'm not sure how to test it properly now, because I don't want to recreate my database again, and that was the command that failed last time - I don't have any actual test setup I'm afraid, I encountered this during fixing some other totally unrelated issue...

CherryDT avatar Jan 15 '22 20:01 CherryDT

@AlexZeitler I'm seeing this issue when running on Windows (While everything works fine on Linux)

TypeError: Jest: Got error running globalSetup - C:\git\fume-community\tests\setup.ts, reason: Cannot read properties of undefined (reading 'trim')
    at C:\git\fume-community\node_modules\docker-compose\dist\v2.js:115:34
    at Array.map (<anonymous>)
    at mapPsOutput (C:\git\fume-community\node_modules\docker-compose\dist\v2.js:88:10)
    at Object.<anonymous> (C:\git\fume-community\node_modules\docker-compose\dist\v2.js:410:52)
    at step (C:\git\fume-community\node_modules\docker-compose\dist\v2.js:44:23)
    at Object.next (C:\git\fume-community\node_modules\docker-compose\dist\v2.js:25:53)
    at fulfilled (C:\git\fume-community\node_modules\docker-compose\dist\v2.js:16:58)

Is this related? Is Windows supported at all?

lizozom avatar Mar 12 '24 12:03 lizozom

I use Windows very rarely and then only as an end user. Maybe we can set up a Windows CI Runner.

AlexZeitler avatar Mar 12 '24 19:03 AlexZeitler