cosmo
cosmo copied to clipboard
fix(cli): write large data synchronously to console before exiting process
Motivation and Context
Problem: We are parsing the raw JSON output of npx wgc subgraph list -n ${namespace} -r and we got the error Unexpected token in JSON at position 8192.. We dug deeper and it seems the bug lies within the asynchronous behavior of console.log and its different implementations across different operating systems (bug was happening on MacOS).
This PR fixes this problem, further described in https://github.com/wundergraph/cosmo/issues/907, by using a synchronous method of writing large data to the console.
I changed console.log to writeToConsoleSync helper function on several places where raw or large data was written to console.
Feel free to comment or suggest any changes.
TODO
- [ ] Tests or benchmark included
- [ ] Documentation is changed or added on https://app.gitbook.com/
- [ ] PR title must follow conventional-commit-standard