vscode-codeql icon indicating copy to clipboard operation
vscode-codeql copied to clipboard

The extension buffers progress messages from the CLI instead of showing them as they happen

Open aschackmull opened this issue 3 years ago • 2 comments

Describe the bug When the extension runs CodeQL CLI commands and those commands attempt to report progress through stderr then the messages are buffered and only shown after the CLI command has finished. This means that slow CLI commands cannot report progress when run through the VSCode extension.

Version CodeQL extension version: 1.6.9 CodeQL CLI version: 2.10.2 Platform: darwin x64

To reproduce Run any query. Then you'll see the CLI command succeeded. message before any [PROGRESS] messages from that CLI command. E.g. something like this:

Generating JSON log summary using CodeQL CLI: generate log-summary -v --log-to-stderr --format=predicates /Users/schack/Library/Application Support/Code/User/globalStorage/github.vscode-codeql/queries/quickquery.ql-d6L9VW0HE6rwNMfIW1ZHx/evaluator-log.jsonl /Users/schack/Library/Application Support/Code/User/globalStorage/github.vscode-codeql/queries/quickquery.ql-d6L9VW0HE6rwNMfIW1ZHx/evaluator-log.summary.jsonl...
CLI command succeeded.
[2022-08-10 11:07:09] [PROGRESS] generate log-summary> Beginning to generate summary for query log located at /Users/schack/Library/Application Support/Code/User/globalStorage/github.vscode-codeql/queries/quickquery.ql-d6L9VW0HE6rwNMfIW1ZHx/evaluator-log.jsonl
[2022-08-10 11:07:09] [PROGRESS] generate log-summary> Continuing to generate log summary: have currently processed about 99% of input file
[2022-08-10 11:07:09] [PROGRESS] generate log-summary> Finished generating log summary
[2022-08-10 11:07:09] [PROGRESS] generate log-summary> Beginning to generate summary for query log located at /Users/schack/Library/Application Support/Code/User/globalStorage/github.vscode-codeql/queries/quickquery.ql-d6L9VW0HE6rwNMfIW1ZHx/evaluator-log.jsonl
[2022-08-10 11:07:09] [PROGRESS] generate log-summary> Continuing to generate log summary: have currently processed about 99% of input file
[2022-08-10 11:07:09] [PROGRESS] generate log-summary> Finished generating log summary

Expected behavior I expect the progress messages from the CLI command to be output while it is running and not be delayed until after it has finished.

Additional context I believe the problem is here: https://github.com/github/vscode-codeql/blob/c3a21b93c0d2b03338e0fa603d4018d27ac85b5f/extensions/ql-vscode/src/cli.ts#L327 The stderr listener just adds the output to a buffer and only outputs it at the end in the finally block: https://github.com/github/vscode-codeql/blob/c3a21b93c0d2b03338e0fa603d4018d27ac85b5f/extensions/ql-vscode/src/cli.ts#L352 Instead the stderr messages ought to go directly to the Extension Log output.

aschackmull avatar Aug 10 '22 09:08 aschackmull

One reason why this happens is that multiple CLI commands can be running at the same time. Outputting logs in this way minimizes the chance that multiple commands will have output interleaved. To be fair, though, I don't know how often this really happens.

aeisenberg avatar Aug 10 '22 21:08 aeisenberg

Outputting logs in this way minimizes the chance that multiple commands will have output interleaved. To be fair, though, I don't know how often this really happens.

I don't think that's an issue. I'm definitely in favour of fixing this - even if it means some output interleaving in some cases (in most cases, I don't think it will).

aschackmull avatar Aug 15 '22 09:08 aschackmull

@stonish Can your team pick this up? I am removing this from our backlog.

aeisenberg avatar Nov 17 '23 22:11 aeisenberg

This should be fixed in the next release of the extension, which is estimated to be in 1-2 weeks.

koesie10 avatar Feb 20 '24 08:02 koesie10