question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BufferTextWriter bugs

See original GitHub issue

https://github.com/microsoft/vs-streamjsonrpc/issues/303 calls out a few exceptions that seem to be thrown erratically as if there’s a race condition, or perhaps specific writing patterns that cause the BufferTextWriter to fail.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
joshlangcommented, Jul 4, 2019

It would be difficult to extra a minimal repo, unfortunately.

Here’s another stack traces:

Error writing JSON RPC Result: InvalidOperationException: Stack empty.//StreamError/System.InvalidOperationException: Stack empty.
   at System.Collections.Generic.Stack`1.ThrowForEmptyStack()
   at System.Collections.Generic.Stack`1.Pop()
   at Nerdbank.Streams.Sequence`1.GetSegment(Int32 sizeHint)
   at Nerdbank.Streams.Sequence`1.GetMemory(Int32 sizeHint)
   at Nerdbank.Streams.BufferTextWriter.EncodeCharacters(Boolean flushEncoder)
   at Nerdbank.Streams.BufferTextWriter.Write(ReadOnlySpan`1 buffer)
   at Nerdbank.Streams.BufferTextWriter.Write(String value)
   at Newtonsoft.Json.Utilities.JavaScriptUtils.WriteEscapedJavaScriptString(TextWriter writer, String s, Char delimiter, Boolean appendDelimiters, Boolean[] charEscapeFlags, StringEscapeHandling stringEscapeHandling, IArrayPool`1 bufferPool, Char[]& writeBuffer)
   at Newtonsoft.Json.JsonTextWriter.WriteEscapedString(String value, Boolean quote)
   at Newtonsoft.Json.JsonTextWriter.WriteValue(String value)
   at Newtonsoft.Json.Linq.JValue.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JProperty.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JObject.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JArray.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JProperty.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JObject.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JProperty.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JObject.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JProperty.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at Newtonsoft.Json.Linq.JObject.WriteTo(JsonWriter writer, JsonConverter[] converters)
   at StreamJsonRpc.JsonMessageFormatter.WriteJToken(IBufferWriter`1 contentBuffer, JToken json)
   at StreamJsonRpc.JsonMessageFormatter.Serialize(IBufferWriter`1 contentBuffer, JsonRpcMessage message)
   at StreamJsonRpc.WebSocketMessageHandler.WriteCoreAsync(JsonRpcMessage content, CancellationToken cancellationToken)
   at StreamJsonRpc.MessageHandlerBase.WriteAsync(JsonRpcMessage content, CancellationToken cancellationToken)
   at StreamJsonRpc.JsonRpc.HandleRpcAsync(JsonRpcMessage rpc)

Again, after happening, we’re stuck in this connect/disconnect loop:

Error writing JSON RPC Result: InvalidOperationException: This instance must be flushed before being reinitialized.//StreamError/System.InvalidOperationException: This instance must be flushed before being reinitialized.
   at Microsoft.Verify.Operation(Boolean condition, String message)
   at Nerdbank.Streams.BufferTextWriter.Initialize(IBufferWriter`1 bufferWriter, Encoding encoding)
   at StreamJsonRpc.JsonMessageFormatter.WriteJToken(IBufferWriter`1 contentBuffer, JToken json)
   at StreamJsonRpc.JsonMessageFormatter.Serialize(IBufferWriter`1 contentBuffer, JsonRpcMessage message)
   at StreamJsonRpc.WebSocketMessageHandler.WriteCoreAsync(JsonRpcMessage content, CancellationToken cancellationToken)
   at StreamJsonRpc.MessageHandlerBase.WriteAsync(JsonRpcMessage content, CancellationToken cancellationToken)
   at StreamJsonRpc.JsonRpc.HandleRpcAsync(JsonRpcMessage rpc)
0reactions
AArnottcommented, Jul 7, 2019

You’re quite welcome.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BufferTextWriter bugs · Issue #91 · dotnet/Nerdbank.Streams
Grr() is our debugging code :) The stack traces etc from above come from the rpc.Disconnected event handler. So, while it's possible that ......
Read more >
Write to the same file using BufferWriter from multiple classes
That means that the data will never be written out to the file. That's why you never see the output. This is the...
Read more >
Cooperative record and replay of concurrency bugs
Another interesting observation is that CoopREPP required fewer replay attempts than CoopREPL for some test cases, namely, BufferWriter,.
Read more >
BufferedWriter (Java Platform SE 7 )
Writes text to a character-output stream, buffering characters so as to provide for the efficient writing of single characters, arrays, and strings.
Read more >
Unable to Create New Lobby After Playing a Match - ...
Hello, I'm encountering a bug in my game where I'm unable to create a new lobby after playing a ... FastBufferWriter& bufferWriter, System....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found