Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inside <style> blocks in html files: Error while computing completions for; Cannot read property 'label' of undefined #47429

Closed
joshunger opened this issue Apr 8, 2018 · 14 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release emmet Emmet related issues verified Verification succeeded

Comments

@joshunger
Copy link
Contributor

joshunger commented Apr 8, 2018

Issue Type: Bug

[Error - 6:12:13 AM] Error while computing completions for file:///Users/junger/dev/private/kitchensink/src/index.html: Cannot read property 'label' of undefined
TypeError: Cannot read property 'label' of undefined
    at Object.<anonymous> (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/html-language-features/server/out/htmlServerMain.js:323:85)
    at step (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/html-language-features/server/out/htmlServerMain.js:36:23)
    at Object.next (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/html-language-features/server/out/htmlServerMain.js:17:53)
    at fulfilled (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/extensions/html-language-features/server/out/htmlServerMain.js:8:58)
    at <anonymous>

VS Code version: Code - Insiders 1.23.0-insider (fc389d2, 2018-04-05T05:10:30.542Z)
OS version: Darwin x64 17.4.0

System Info
Item Value
CPUs Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz (4 x 3100)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.25GB free)
Process Argv /Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron ./
Screen Reader no
VM 0%
Extensions (10)
Extension Author (truncated) Version
sort-lines Tyr 1.6.0
vscode-eslint dba 1.4.8
prettier-vscode esb 1.2.2
python ms- 2018.3.1
java red 0.22.0
vscode-fileutils sle 2.8.1
vscode-java-debug vsc 0.8.0
vscode-java-pack vsc 0.3.0
vscode-java-test vsc 0.5.0
vscode-maven vsc 0.6.0

I don't have repro steps but if you can tell me context I can estimate the issue and repro steps.
@vscodebot vscodebot bot added the insiders label Apr 8, 2018
@vscodebot
Copy link

vscodebot bot commented Apr 8, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@fuzzykiller
Copy link

This issue also occurs on version Version 1.22.1 (950b8b0).

I think it’s a race condition that happens when I delete text VS Code is trying to provide a suggestion with. However, I don’t have reliable repro steps. It appears to happen frequently when editing CSS embedded in a <style> tag in a plain HTML document.

@joshunger
Copy link
Contributor Author

@fuzzykiller same here, I was editing CSS in a <style> in a .html document

@ramya-rao-a ramya-rao-a assigned aeschli and unassigned ramya-rao-a Apr 10, 2018
@ramya-rao-a ramya-rao-a added the css-less-scss Issues and items concerning CSS,Less,SCSS styling label Apr 10, 2018
@ramya-rao-a
Copy link
Contributor

@aeschli
Copy link
Contributor

aeschli commented Apr 10, 2018

@ramya-rao-a htmlServerMain.js:323 is
if (hexColorRegex.test(emmetCompletionList.items[0].label) && result.items.some(function (x) { return x.label === emmetCompletionList.items[0].label; })) {

Are you sure about https://github.com/Microsoft/vscode/blob/master/extensions/css-language-features/server/src/cssServerMain.ts#L198? What's wrong there?

@aeschli aeschli assigned ramya-rao-a and unassigned aeschli Apr 10, 2018
@aeschli
Copy link
Contributor

aeschli commented Apr 10, 2018

Looks like #47384

@joshunger
Copy link
Contributor Author

@aeschli thanks let us know if you need any help

@vscodebot vscodebot bot removed the insiders label Apr 10, 2018
@ramya-rao-a ramya-rao-a added emmet Emmet related issues and removed css-less-scss Issues and items concerning CSS,Less,SCSS styling labels Apr 10, 2018
@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Apr 10, 2018

Sorry about that @aeschli, yes this is coming from htmlServerMain and is same as #47384

I'll add the null/undefined check, but I am curious as to what conditions lead to this error as I cannot backtrack and see any case where the completion items is not an array in a completion list.

@joshunger Can you repro this consistently? If yes, then can you provide sample code and steps?

@joshunger
Copy link
Contributor Author

@ramya-rao-a no

@fuzzykiller
Copy link

@ramya-rao-a Just spam Ctrl+Space and Backspace (or Ctrl+Backspace because it's easier to keep pressing Ctrl) inside a <style> element. It's quite reliable.

It does not happen in CSS files, only in HTML files.

@ramya-rao-a ramya-rao-a added bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release labels Apr 10, 2018
@ramya-rao-a ramya-rao-a added this to the March Recovery 2018 milestone Apr 10, 2018
@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Apr 10, 2018

Thanks @fuzzykiller

Steps to verify fix:
Inside a <style> block in an html file have a css rule as below:

<style>
        body {
            background-color: #000000;
            disp
        }
    </style>
  • Type l after the disp. You should get suggestions and not errors in the output channel for HTML language server
  • Trigger suggestions after typing either font- or background- (basically any css property that has a - in the middle, type only till the - and then esc to remove existing suggestions and then trigger suggestions manually). You should get suggestions and not errors in the output channel for HTML language server

@ramya-rao-a ramya-rao-a changed the title Error while computing completions for; Cannot read property 'label' of undefined Inside <style> blocks in html files: Error while computing completions for; Cannot read property 'label' of undefined Apr 10, 2018
@joshunger
Copy link
Contributor Author

Thanks 👏 @ramya-rao-a

@dmbdesignpdx
Copy link

Hi,
I'm still getting errors in the output channel with the fix suggestion.

Inside an inline <style> in an .html file, if I start typing...

#test {
   border-
}

then escape the suggestions, and continue typing...

#test {
   border-b
}

I get the error.

It also happens during this scenario:

  1. I type the whole property without any deletions or select the suggestion to auto-complete
  2. delete the characters until the hyphen
  3. start retyping the property

This seems to be consistent only with the first letter of the second part of a hyphenated property. For example:

  • border-t for top or
  • border-c for collapse
    will throw the error without any suggestions for auto-complete.

BUT if I start off with a letter that is post-first letter, i.e.: border-a, border-k, border-y, etc. it will NOT throw an error and will provide me with suggestions to auto-complete.


The error:

[Error - 23:38:11] Error while computing completions for untitled:Untitled-1: Cannot read property 'label' of undefined
TypeError: Cannot read property 'label' of undefined
    at Object.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/html-language-features/server/out/htmlServerMain.js:323:84)
    at step (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/html-language-features/server/out/htmlServerMain.js:36:23)
    at Object.next (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/html-language-features/server/out/htmlServerMain.js:17:53)
    at fulfilled (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/html-language-features/server/out/htmlServerMain.js:8:58)
    at <anonymous>

My info:

VS Code version: Code 1.22.1 (950b8b0, 2018-04-06T00:21:13.607Z)
OS version: Darwin x64 17.5.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4750HQ CPU @ 2.00GHz (8 x 2000)
Load (avg) 3, 2, 2
Memory (System) 8.00GB (0.30GB free)
Process Argv /Applications/Visual Studio Code.app/Contents/MacOS/Electron
Screen Reader no
VM 0%
Extensions: none (6 theme extensions excluded)

Hope that made sense; please let me know!

@ramya-rao-a
Copy link
Contributor

@dmbdesignpdx You are on stable VS Code version 1.22.1 The fix is currently available in the Insiders build of 1.23. The fix will also be shipped in stable VS Code version 1.22.2 in a few days

@octref octref added the verified Verification succeeded label Apr 11, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators May 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release emmet Emmet related issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants