Fix --log-file
option so it doesn't crash the server.
#207
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This fixes #181.
The problem was that calling
flush
causes the stream to bind to the flush call, so the next time add (or flush) is called, it throws. However theError
was being eaten by a catch somewhere, so I had to dig a bit to get the trace:So, the solution is the same as the old comedy bit: "Patient: Doctor, it hurts when I do this... Doctor: well don't do that".
I just took out the
flush
and things work, and the the log appears to be flushed at each line anyhow.It seems that
flush
in Dart is basically just waiting for the output stream to be empty; it doesn't force anything to be sent to the disk, and since we don't have to make sure things are in the log before adding more to the log, we don't really need theflush
.In the course of investigating, I also found that a there were a couple of uninitialized
late final
accesses that were also being swallowed in the analyzer support, so I converted them to nullables and only call them if they are set. This was happening when the shutdown occurred on a client that didn't support roots.Also added a check for an unset
protocolVersion
because I ran into that too, but I'm not clear on whether it should throw there or just returnnull
. I opted to returnnull
in that case, since a nullprotocolVersion
is allowed.Related Issues
Tests