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.

`JsonReaderException: Unterminated string` sending first DebugAdapter message

See original GitHub issue

Hello

I’m trying to debug a .NET Core app over SSH on a Docker container that’s running on a remote server. I read your offroad debugging docs and learned a lot by trial and error talking to vsdbg. I’m able to run the plink/ssh command in a shell, paste a JSON message (with Content-Length; see picture) and get the remote app to talk back to me. However, when doing the same in Visual Studio 2019 the DebugAdapter throws a JsonReaderException and often doesn’t send any data to the remote (but sometimes it does send!).

Here’s my launch.json, the comments are for my team:

// This is for anyone working in Visual Studio to debug _remote_ Docker
// containers via SSH to ca-vic-app01 in QA
// View->Other Windows->Command Window
// DebugAdapterHost.Logging /On /OutputWindow
// DebugAdapterHost.Launch /LaunchJson:"<THIS FILE.json>" /EngineGuid:541B8A8A-6081-4506-9F0A-1CE771DEBC04
{
	// Docs on launch.json:
	// https://github.com/Microsoft/MIEngine/wiki/Offroad-Debugging-of-.NET-Core-on-Linux---OSX-from-Visual-Studio
	"version": "0.2.0",
	"adapter": "C:\\Program Files\\PuTTY\\plink.exe",
	// Change the container name here. Must be built with debugging symbols and
	// include the remote debugger via bind mount or the Dockerfile
	"adapterArgs": "-i \"C:\\id.ppk\" user@ca-vic-app01 -t -batch docker attach maestro-api-debug-vsdbg",
	"configurations": [
		{
			"name": ".NET Core Remote Docker Attach",
			"type": "coreclr",
			"request": "attach",
			"processId": 1
		}
	]
}
// If you just want to do local Docker debugging, install this:
// https://marketplace.visualstudio.com/items?itemName=Dreamescaper.AttachToDockerContainer

I’m running these in the command window:

>DebugAdapterHost.Logging /On /OutputWindow /Verbosity:debug
>DebugAdapterHost.Launch /LaunchJson:"C:\Projects\EFX\launch.json" /EngineGuid:541B8A8A-6081-4506-9F0A-1CE771DEBC04

I get a pop up of the error and this output:

 1> DebugAdapterHost version: 16.0.30220.2 commit:37bf7cc091107568bd6aa14b6229bb6741ce945f
 1> State: Unset => Initializing
 1> Sending VS event: IDebugEngineCreateEvent2 (fe5b734c-759d-4e59-ab04-f103343bdd06)
 1> Sending VS event: IDebugProgramCreateEvent2 (96cd11ee-ecd4-4e89-957e-b5d496fc4139)
 1> Starting 'C:\Program Files\PuTTY\plink.exe' with arguments '-i "C:\id.ppk" user@ca-vic-app01 -t -batch docker attach maestro-api-debug-vsdbg'
 1> [DebugAdapter] --> C (initialize-1): {"command":"initialize","arguments":{"clientID":"visualstudio","clientName":"Visual Studio","adapterID":"coreclr","locale":"en-US","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsRunInTerminalRequest":true,"supportsHandshakeRequest":true},"seq":1,"type":"request"}
 1> WARNING: Stopping due to fatal error: JsonReaderException: Unterminated string. Expected delimiter: ". Path 'type', line 3, position 313.
 1> Cancelling outstanding request(s) with ID(s): 1
 1> ERROR: Debug Adapter did not respond to initial requests.
 1> ERROR: Unexpected error

AggregateException: One or more errors occurred.

Aggregate exception: 
    DebugAdapterLaunchException: Failed to launch debug adapter.  Additional information may be available in the output window.

    Failure Location: UserCanceled
    Inner Exception: 
        OperationCanceledException: The operation was canceled.
Inner Exception: 
    DebugAdapterLaunchException: Failed to launch debug adapter.  Additional information may be available in the output window.

Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.Engine.Implementation.DebuggedProcess.<StartDebugAdapter>b__91_1(Exception ex)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.Utilities.TaskExtensions.<>c__DisplayClass11_0`1.<Catch>b__0(TException ex)
Microsoft.VisualStudio.Debugger.VSCodeDebuggerHost.Utilities.TaskExtensions.<>c__DisplayClass10_0`1.<Catch>b__0(AggregateException ex)

    Failure Location: UserCanceled
    Inner Exception: 
        OperationCanceledException: The operation was canceled.

 1> ERROR: One or more errors occurred.

Failed to launch debug adapter.  Additional information may be available in the output window.

The operation was canceled.
 1> Sending VS event: IDebugErrorEvent2 (fdb7a36c-8c53-41da-a337-8bd86b14d5cb)
 1> State: Initializing => Exiting
 1> State: Exiting => Exited
 1> Sending VS event: IDebugProgramDestroyEvent2 (e147e9e3-6440-4073-a7b7-a65592c714b5)
 1> ERROR: Unexpected error

JsonReaderException: Unterminated string. Expected delimiter: ". Path 'type', line 3, position 313.

Newtonsoft.Json.JsonTextReader.ReadStringIntoBuffer(Char quote)
Newtonsoft.Json.JsonTextReader.ParseString(Char quote, ReadType readType)
Newtonsoft.Json.JsonTextReader.ParseValue()
Newtonsoft.Json.JsonTextReader.Read()
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues(JsonObjectContract contract, JsonProperty containerProperty, JsonReader reader, Type objectType)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor`1 creator, String id)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean& createdFromNonDefaultCreator)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.HandleIncomingMessage(String msg)
Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.ProcessMessageBody()
Microsoft.VisualStudio.Shared.VSCodeDebugProtocol.Protocol.DebugProtocol.ReaderThreadProc()

 1> ERROR: Unterminated string. Expected delimiter: ". Path 'type', line 3, position 313.
 1> Sending VS event: IDebugErrorEvent2 (fdb7a36c-8c53-41da-a337-8bd86b14d5cb)
 1> Debug adapter process exited.
 1> Debug adapter non-protocol standard output: st"}

It says it’s “user canceled” but I’m not touching anything else after running it.

I’m using docker attach in my launch.json above, but the issue also happens for docker exec -it /opt/vsdbg/vsdbg --interpreter=vscode or even on the Linux host with /home/user/vsdbg/vsdbg --interpreter=vscode. I don’t think it’s an issue on the remote, I think it’s in VS2019/DebugAdapter…

The DebugAdapter always throws an error, but sometimes (once or twice) the message is sent before it crashes, and this is what I see:

image

Which is valid JSON! So I’m not sure why it thinks the st" is being cut off. Although I was concerned if it had to do with the Content-Length header and then have 3 newlines in the output? Might not be related.

I didn’t see any issues about this, or JSON, or unterminated strings in this repo or Omnisharp’s. Have you seen something like this before?

Thanks for all your work into this project!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
paulmaybeecommented, Aug 15, 2019

I’m not familiar with your scenario at all, but looking at your json it looks like this line is improperly formatted. It looks like it is missing a ‘\’ after the “ppk”.

              "adapterArgs": "-i \"C:\\id.ppk" user@ca-vic-app01 -t -batch docker attach maestro-api-debug-vsdbg",
0reactions
gregg-miskellycommented, Aug 20, 2019

Thanks! I made a few tweaks and merged in your changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Newtonsoft.Json.JsonReaderException: Unterminated ...
I receive this exception during parsing string containing JSON: Newtonsoft.Json.JsonReaderException: Unterminated string. Expected delimiter: ".
Read more >
Newtonsoft.Json.JsonReaderException Error when editing ...
Hi,. Pasted error below, all I'm adding to a XhtmlString property is standard HTML, as soon as I save and then try to...
Read more >
Import error Unterminated string - Uncategorised
Hi, I've installed Octopus Deploy 2.3.3.1369-x64 successfully. However when I try to import our settings from our old version 1.6.1.1718, ...
Read more >
Error encountered by JSON parser: Unterminated string
This is the error I am getting after the request data is sent: {"error":{"code":"InvalidRequest","message":"Error parsing request for dataset ...
Read more >
Unterminated string constant? : r/javascript
that error means that a string isn't closed by a matching quote mark. it looks like your string in append() is split on...
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