Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CherryDT opened this issue Aug 7, 2021 · 6 comments

Comments

@CherryDT
Copy link

CherryDT commented Aug 7, 2021

Causing this issue downstream: cardano-foundation/cardano-graphql#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.

@Steveb-p
Copy link
Contributor

Steveb-p commented Aug 7, 2021

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.

@AlexZeitler
Copy link
Contributor

Yes, should be possible.

karolyp pushed a commit to karolyp/docker-compose that referenced this issue Jan 14, 2022
karolyp added a commit to karolyp/docker-compose that referenced this issue Jan 14, 2022
karolyp added a commit to karolyp/docker-compose that referenced this issue Jan 14, 2022
karolyp added a commit to karolyp/docker-compose that referenced this issue Jan 14, 2022
karolyp added a commit to karolyp/docker-compose that referenced this issue Jan 14, 2022
AlexZeitler pushed a commit that referenced this issue Jan 14, 2022
* fix(#178): fix quiet trim issue, add tests

* chore: add trim for carriage return in version()
@AlexZeitler
Copy link
Contributor

@CherryDT Did #197 fix this for you?

@CherryDT
Copy link
Author

CherryDT commented Jan 15, 2022

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...

@lizozom
Copy link

lizozom commented Mar 12, 2024

@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?

@AlexZeitler
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants