cosmo icon indicating copy to clipboard operation
cosmo copied to clipboard

fix(cli): write large data synchronously to console before exiting process

Open alumpe opened this issue 1 year ago • 1 comments

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

alumpe avatar Jul 10 '24 08:07 alumpe