DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Josh Pinkney
Josh Pinkney

Posted on

Tracking down the painful bugs

A few months ago I was helping a co-worker fix a bug in the XML language server that had to do with the hover feature. The bug wasn't throwing exceptions, attempts to debug it yielded no results that were easily found and for some reason, the language server just kept crashing. It wasn't really clear at all what was happening and the code just sort of died. Since this bug was seemingly undetectable we spent a really long time (probably more then we should have) doing a brute force comment out of sections that we thought might have been causing the issue.

What's sad/funny is what was actually going on. For those of you who don't know, language servers connect to a client (such as VSCode) and VSCode sends requests to the server based on a user event. For example, if you hover over an element it sends a request to the server and the server sends a response back. The language server protocol dictates what should be sent/returned for a request/response. The bug was extremely simple and rather funny, but painful to debug. Basically what was happening was there was

System.out.println("test");

inside of the part of the server that controls what happens when you hover over an element. Since VSCode was seeing that we were trying to hover, it would send a hover request to the server. The server would then react but when it hit

System.out.println("test");

it was sending back "test" to the client, resulting in the language server crashing.

Let me know your worst bug experience in the comments!

Top comments (0)

πŸ€” Did you know?

Β 
πŸ“š You can adjust your experience level in Settings to see more relevant content.