microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.98k stars 29.53k forks source link

"Parse error on line 1: Expecting 'STRING'..." - How do I find out what extension is causing this issue? #96837

Closed macintacos closed 4 years ago

macintacos commented 4 years ago

Issue Type: Bug

I have a very reliable issue when it comes to opening new, untitled files that start out as plaintext (a very common usage pattern for me). I start typing, and everything is fine, but then when I delete that line of text, I get the following error which does not go away until I reload the window:

Parse error on line 1:

^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got '1'

Here's a gif demonstrating the issue.

My question is not how do I fix this, because I've already searched other issues that have been opened here (e.g. #67046, #56193) and see that it's probably an extension and I have to go hunt it down. The problem is that I have a lot of (probably too many) extensions, and I can imagine that this will get tedious trying to hunt it down.

VSCode doesn't really provide anything useful about what extension generated the error that I'm seeing. When I right click and copy the message, I'm given this information, which I don't find to be particularly helpful:

{
    "resource": "Untitled-1",
    "owner": "languageErrors31",
    "severity": 8,
    "message": "Parse error on line 1:\n\n^\nExpecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got '1'",
    "startLineNumber": 1,
    "startColumn": 1,
    "endLineNumber": 1,
    "endColumn": 1
}

Is owner supposed to have meaningful significance to help me debug this? I've searched around and this doesn't really give me much to go by.

Can I get some pointers on how to tackle this properly so that I don't waste an hour trying to figure it out (teach a man to fish and all that)? If the only solution really is "disable extensions one by one", can we use this issue as a catalyst to make this better/easier to debug? I couldn't find any issues that are trying to tackle this problem specifically, but please let me know if this is a duplicate and I'll go chime in there.

VS Code version: Code 1.44.2 (ff915844119ce9485abfe8aa9076ec76b5300ddd, 2020-04-16T17:07:18.473Z) OS version: Darwin x64 19.3.0

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (16 x 2300)| |GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
viz_display_compositor: enabled_on
viz_hit_test_surface_layer: disabled_off_ok
webgl: enabled
webgl2: enabled| |Load (avg)|4, 4, 4| |Memory (System)|32.00GB (0.08GB free)| |Process Argv|-psn_0_147492| |Screen Reader|no| |VM|0%|
Extensions (136) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|2.0.5 html-snippets|abu|0.2.1 scss-lint|ada|0.1.10 vscode-caniuse|aga|0.5.0 vscode-javascript-snippet-pack|aka|0.1.5 Bookmarks|ale|11.1.0 project-manager|ale|10.12.0 spellright|ban|3.0.50 search-crates-io|bel|1.2.1 color-info|bie|0.5.1 emojisense|bie|0.6.1 github-markdown-preview|bie|0.0.2 markdown-checkbox|bie|0.1.3 markdown-emoji|bie|0.0.9 markdown-preview-github-styles|bie|0.1.6 markdown-yaml-preamble|bie|0.0.4 htmltagwrap|bra|0.0.7 better-toml|bun|0.3.2 markdown-jira|chi|1.1.0 path-intellisense|chr|1.4.2 open-html-in-browser|cod|0.1.21 gitignore|cod|0.6.0 bracket-pair-colorizer-2|Coe|0.0.29 disableligatures|Coe|0.0.8 compulim-vscode-closetag|Com|1.2.0 vscode-svgviewer|css|2.0.0 perl-toolbox|d97|1.4.0 transformer|dak|1.6.0 scala|dal|0.0.5 vscode-markdownlint|Dav|0.35.1 vscode-dash|dee|2.4.0 confluence-markup|den|0.1.8 binary-plist|dni|0.4.0 git-extension-pack|don|0.1.3 githistory|don|0.6.5 xml|Dot|2.5.0 gitlens|eam|10.2.1 vscode-html-css|ecm|0.2.3 EditorConfig|Edi|0.14.5 LogFileHighlighter|emi|2.8.0 vscode-great-icons|emm|2.1.47 prettier-vscode|esb|4.5.0 vscode-open-in-github|fab|1.2.3 vimL|fal|0.0.3 markdown-table-formatter|fcr|2.0.4 vscode-firefox-debug|fir|2.7.2 code-runner|for|0.10.0 shell-format|fox|7.0.1 sort-json-array|fvc|2.0.1 nightswitch|gha|1.1.0 vscode-pull-request-github|Git|0.15.0 gc-excelviewer|Gra|2.1.34 todo-tree|Gru|0.0.174 vscode-settings-cycler|hoo|1.0.1 snooty|i80|0.0.10 output-colorizer|IBM|0.1.2 applescript|idl|0.18.2 smarty|imp|0.3.0 customize-ui|ioc|0.1.35 monkey-patch|ioc|0.1.7 path-autocomplete|ion|1.13.6 hungry-delete|jas|1.6.0 docthis|joe|0.7.1 TypeScriptImport|kev|1.17.0 json2csv|kha|0.0.1 vscode-gutter-preview|kis|0.26.1 git-indicators|lam|2.1.2 vscode-fix-checksums|leh|1.1.0 node-module-intellisense|lei|1.5.0 expand-region|let|0.1.4 bash-ide-vscode|mad|1.9.1 rust-analyzer|mat|0.2.151 Lisp|mat|0.1.10 terraform|mau|1.4.0 rainbow-csv|mec|1.7.0 git-graph|mhu|1.22.0 ecdc|mit|1.3.0 HTMLHint|mka|0.6.0 mongodb-vscode|mon|0.0.1 vscode-docker|ms-|1.1.0 csharp|ms-|1.21.17 vscode-kubernetes-tools|ms-|1.2.0 python|ms-|2020.4.76186 cpptools|ms-|0.27.1 Go|ms-|0.14.1 debugger-for-chrome|msj|4.12.6 vscode-paste-image|mus|1.0.4 color-highlight|nau|2.3.0 autodocstring|njp|0.5.1 vscode-extension-auto-import|Nuc|1.4.3 indent-rainbow|ode|7.4.0 fix-json|oli|0.1.2 advanced-new-file|pat|1.2.0 markdown-checkbox|PKi|1.7.0 vscode-css-peek|pra|3.0.2 text-power-tools|qcz|1.11.1 subtle-brackets|raf|3.0.0 vscode-xml|red|0.11.0 vscode-yaml|red|0.7.2 shellman|Rem|4.4.0 vscode-sort-json|ric|1.18.0 bash-debug|rog|0.3.7 zsh-debug|rog|0.1.3 partial-diff|ryu|1.4.1 multi-command|ryu|1.4.0 vscode-javascript-booster|sbu|0.12.3 crates|ser|0.4.9 code-settings-sync|Sha|3.4.3 trailing-spaces|sha|0.3.1 mdx|sil|0.1.0 vscode-fileutils|sle|3.0.1 guides|spy|0.9.3 autoimport|ste|1.5.3 rewrap|stk|1.9.1 code-spell-checker|str|1.8.0 ayu|tea|0.18.0 shellcheck|tim|0.9.0 tmlanguage|Tog|0.9.0 go-to-method|tri|0.2.0 sort-lines|Tyr|1.9.0 errorlens|use|3.1.1 vscode-lldb|vad|1.5.0 highlight-matching-tag|vin|0.9.9 vscodeintellicode|Vis|1.2.6 vscode-icons|vsc|10.1.1 vim|vsc|1.13.1 gistfs|vsl|0.0.66 vscode-todo-highlight|way|1.0.4 change-case|wma|1.0.0 better-align|wwm|1.1.6 clang-format|xav|1.9.0 vs-code-wiki|Yun|0.4.8 markdown-all-in-one|yzh|2.8.0 material-theme|zhu|3.3.1 html-css-class-completion|Zig|1.19.0 vscode-open-in-github|ziy|1.3.6 (8 theme extensions excluded)
sandy081 commented 4 years ago

Generally extension creating these diagnostics shall add the source of the diagnostic which is missing in this case. I do not think we have extension information available in our diagnostics model and I see this is useful in the case.

@jrieken Is it possible to add extension id as source if missing?

jrieken commented 4 years ago

@jrieken Is it possible to add extension id as source if missing?

Sure but I don't think that makes sense because we show them quite prominent in the UX and extension ids and often also names aren't fit for that.

sandy081 commented 4 years ago

Ok. How about having extension info (id) available in the marker so that we can provide this info in the copy action?

jrieken commented 4 years ago

That. Or how about trace logging what extension is adding what marker to what files?

sandy081 commented 4 years ago

Either works for me.

macintacos commented 4 years ago

Thanks, all! Whatever makes these kinds of issues easier to debug and makes me less likely to open a new issue is great in my book 🙂

jrieken commented 4 years ago

@sandy081 I'll push a change for some trace logging

jrieken commented 4 years ago

There is now (very) verbose logging in the 'Extension Host Log' whenever an extension updates diagnostics

jrieken commented 4 years ago

to verify:

  1. enable verbose logging
  2. check the extension host log for messages starting with [DiagnosticCollection]
macintacos commented 4 years ago

@jrieken I can't figure out how to enable verbose logging and can't find it in the documentation, do you have any pointers?

macintacos commented 4 years ago

Ah okay I figured out, set it to "trace" and I see the following output:

[2020-05-29 13:08:28.260] [exthost] [warning] DiagnosticCollection with name 'languageErrors' does already exist.
[2020-05-29 13:08:28.267] [exthost] [trace] [DiagnosticCollection] change many (extension, owner, uris) Togusa09.tmlanguage languageErrors68 [[{"$mid":1,"fsPath":"extHostLog","external":"output:extHostLog","path":"extHostLog","scheme":"output"},[]]]

Guess I gotta go bring this up in the TextMate Languages extension, since disabling that fixes the issue. Thanks again!