Bref:cli - After upgrade from 1.7 to 2.1, comands output data twice

34 Views Asked by At

I am updating our bref/bref library from 1.7 to 2.1 and I see that the way the CLI tool is used has changed between versions. Here is my bref command under 1.7. It calls a symfony command and makes an SQL query to multiple databases at the same time:

vendor/bin/bref cli my-lambda-production-console --region us-east-1 -- production:foreach -o csv "SELECT COUNT(id) FROM mytable" > mytable-us.csv

This usually outputs a CSV of database name and count from the query:

START 
SQL to execute: SELECT COUNT(id) FROM mytable 
Running ConnectAll.
dbname1,3 
dbname2,4 
dbname3,1 
dbname4,1 
dbname5,2
All done. 
END Duration: 1252.94 ms Memory Used: 185 MB

After upgraded bref/bref, it seems the new command should be this. And this works, but the output now includes a large JSON string at the top that appears to be just a duplicate of the outputed data.

New command:

serverless bref:cli --region=us-east-1 --stage=production --function=console --args="production:foreach 'SELECT COUNT(id) FROM mytable'" > mytable-us.out

Output:

{
  "exitCode": 0,
  "output": "SQL to execute: SELECT COUNT(id) FROM mytable\nRunning
 ConnectAll.\dbname1,3\dbname2,4\dbname3,1\dbname4,1\dbname5,2\nAll
 done.\n" 
}
START 
SQL to execute: SELECT COUNT(id) FROM mytable 
Running ConnectAll.
dbname1,3 
dbname2,4 
dbname3,1 
dbname4,1 
dbname5,2
All done. 
END Duration: 1252.94 ms Memory Used: 185 MB

As you can see, the contents of the JSON string is identical to the output we are expecting. Is anyone aware of what is causing the first JSON block of output. It doesn't happen on bref 1.7. I imagine that serverless is a possible culprit, but I've struggled to find any clues in either docs.

1

There are 1 best solutions below

0
On

I commented out 2 lines in

vendor/bref/bref/src/ConsoleRuntime/Main.php

to avoid duplicate output when running bref:cli commands CHANGED LINES:

return [
    // 'exitCode' => $exitCode, // will always be 0
    // 'output' => $process->getOutput(),
];

it fixed the visual issue and no side effects so far