Vscode: Git: Cannot read property 'resourceUri' of undefined

Created on 6 Oct 2017  路  40Comments  路  Source: microsoft/vscode

  • VSCode Version: Code - Insiders 1.17.0-insider (7ac1f1e05baad03d4dd8f8515f1e598180b2c97e, 2017-09-30T05:06:21.234Z)
  • OS Version: Windows_NT x64 6.1.7601
  • Extensions:

Extension|Author (truncated)|Version
---|---|---
vscode-eslint|dba|1.3.2
githistory|don|0.2.3
xml|Dot|1.9.2
Go|luk|0.6.66
code-beautifier|mic|1.7.2
vscode-icons|rob|7.14.0
vscode-table-formatter|shu|1.2.1
addDocComments|ste|0.0.8

(1 theme extensions excluded)


Steps to Reproduce:

  1. Open the Git Sidebar
  2. Click on the 'Discard changes' button filename: fetch.go
  3. Then the following error occurs:
    image

Developer Tools:
image


Reproduces without extensions: Yes/No

bug git verified

Most helpful comment

OK GUYS! I got it, finally.

homer

Steps:

  1. Have 4 unstaged files: file1.txt, file2.txt, file3.txt, file4.txt.
  2. In the terminal, type git add file1.txt file3.txt
  3. Using the UI, stage file2.txt then unstage it. Repeat this 5 more times.
  4. Try clicking on file4.txt or any of its actions.

spongebob

Keep reading for a _postmortem_ analysis.


Here's where the bug is:

https://github.com/Microsoft/vscode/blob/0a42516de80d3141955114678b5736c5d124f796/src/vs/workbench/api/node/extHostSCM.ts#L265

We're basically dealing with a list of changes, sorted by the occurring index in the original sequence, and applying the same changes into a another list. This, of course, is a problem if the difference between the number of inserted elements is different than the number of deleted elements in that change, since the index positions for the following changes will all be wrong. The usual way to do this is to reverse the list of changes and apply them in that order. We do this in the main thread:

https://github.com/Microsoft/vscode/blob/0a42516de80d3141955114678b5736c5d124f796/src/vs/workbench/api/electron-browser/mainThreadSCM.ts#L179

But we overlooked doing the same when dealing with the _handlesSnapshot array.

Combine that with the fact that we only really dispose these guys 10 times after a resource group was effectively modified (that's why step 3 of the repro steps needs to be repeated 5 times), this bug proved to be a very elusive one.

lesson


I'll fix the order of handling these splices. I'll also remove the 10 generations before disposing... we can deal with that in some other way.

All 40 comments

Looks like that this is the same problem like in #33819 and #33389

Must be a new issue since you are on 1.17.0.

Version 1.17.0 (1.17.0)

Git: Cannot read property 'resourceUri' of undefined
e.doShow @ /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.main.js:28

@maxibanki @pftbest Does the issue reproduce easily?

It happened just one time while i was on work. No way to reproduce it currently as i know.

Happening as I am typing this.
I tried to press + to add a file that already exists in the Git repo and this error kept popping up. And it did not go away so I typed "git commit -am '[commit-message]'" into the console and could commit just fine, however adding using the GUI caused the problem as seen in the screenshot.

screen shot 2017-10-11 at 3 42 37 pm

Hope this helps
I have included the output console in the screenshot to show as much as possible.

One workaround I found was to open a different folder, and then go back to opening the original folder.

The issue appeared to fix itself then.

Same message when trying to stage changes done in an untracked folder.

Worked around it by manually adding the folder with git add folderName/

Having this issue when trying to stage changes as well as clicking on the file and trying to see the diff. Worked smoothly before an update

It happened to me twice yesterday, and in both cases i was editing files that where outside of current workspace but in the same git repo.

It happened with c++ when I've tried to add a new source file.

I have a bunch of files right now project that is like these, but other files are fine. Is hard to reliably reproduce as only some files sometimes becomes problematic. If I restart vscode all files can be fine. I've seen this in multiple projects which differ quite a bit so I have no idea what the common thing could be.

Add the particular files by going to the directory in your terminal(right click on the folder in your project and open it in terminal) and add all the files you want.

me too

try to perform action using terminal, it worked for me,

This seems very hard for me to reproduce. It's very possible that https://github.com/Microsoft/vscode/commit/9e9f809fc0d43f4b5079eaeb37cd8a986cce14e4 fixed it. But not sure...

I'l close it for now. Please try the latest Insiders release or the upcoming November stable release (available next week) and let me know if you still see the issue.

For verification, I tried running this command a number of times and did not see the error being hit. Not sure if it only reproduces under certain configurations

As @joaomoreno said, let us know if you hit this again in the current insiders builds

Was seeing this issue on a single file constantly, in different projects (diff file in diff projects). Relaunching vscode to install 1.17.2 made problem go away. Will report back if begins happening again.

@joaomoreno I had the issue again with this version:

  • VSCode Version: Code - Insiders 1.18.0-insider (098bb776d2e5fdf3cc9ea27a233754acf4309857, 2017-11-04T04:43:03.436Z)
  • OS Version: Windows_NT x64 6.1.7601

So the commit 9e9f809 doesn't fixed the issue.
Here some details, which maybe helps you to reproduce it better:

I opened the SCM sidebar and tried to type in a Git commit message. After that I want to view the difference for some files.
image
All files worked fine to see the difference except the package.json. When I try to click on the file, no error appears. Also the Stage Changes and the Discard button works fine except on the package.json. In this example the files had a difference where the last line got removed. (I checked it via the git diff command from the command line). When I clicked on the Stage Changes and the Discard button the error message from the issue title appears via a Message on the top.

on version 1.18.0 as well. sporadic but a lot of files I can't stage changes or view the changes. Git: Cannot read property 'resourceUri' of undefined. +1 to make this high priority

Getting this aswell on 1.18.0, seems hard to reproduce

Me too for 1.18.0, if I have eg. 10 files to commit there is certainly at least one of them which fails with this message

This has actually gotten seemingly worse for me since my most recent update (1.18.0). Not only am I seeing the resourceUri error, but in some cases I can't even open the file from the source control tab. Right now I have a file in "Changes" and double clicking it does nothing -- it doesn't open it (or the diff), and I don't even get any sort of error. If I try to stage it I still get the "Git: Cannot read property 'resourceUri' of undefined" error message."

As everyone else is reporting, using the command line works just fine (and the source control tab updates accordingly), so it's not a huge problem for me, just a minor annoyance.

Unfortunately I haven't found a reliable way to reproduce this, but it's happening often enough for me that if anyone has any ideas I'm happy to test them out.

Guys, if you open the Developer Tools, is there any warning in there?

Another possible workaround: pass by your terminal and add manually the file
git add <your-file>

VS Code
Version 1.18.0
Commit dcee2202709a4f223185514b9275aa4229841aa7
Date 2017-11-08T12:44:48.751Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

You'll be able to see the differences through the editor then.

This has actually gotten seemingly worse for me since my most recent update (1.18.0). Not only am I seeing the resourceUri error, but in some cases I can't even open the file from the source control tab.

Hmm, for me it has always been that way. However the file can still be opened from the file tree.

Questions for those who hit this:

  • Is there any special output in the Developer Tools when this happens?
  • Do you have more than a single SCM repository in the SCM view?

In my case only the output (of the first post in this issue) was logged. I haven't used or installed any other SCM provider.

I get this in the Developer Tools console when a file won't open:

screen shot 2017-11-15 at 8 05 35 pm

And to answer your other question @joaomoreno - I only have one SCM repository.

The bug is there!
Arch Linux and VSCODE 1.18.0

When I've tried to stage only with some (apparently random) files I've had the problem.

Recently also the git.autorefresh does not work!
I've set in my config git.autorefresh": true .

In the developper tools i've found this:

messageService.ts:126 GIT: Cannot read property 'resourceUri' of undefined
e.doShow @ messageService.ts:126

Also available on OSX 10.12.6 vscode 1.18.0

Tried to add a modified file to stage.
Shortly after i added other files to stage without a problem.
Then i retried to add the "problem" file and got the error again.

got two messages:

messageService.ts:126 Git: Cannot read property 'resourceUri' of undefined
e.doShow @ messageService.ts:126
e.show @ messageService.ts:105
e._showMessage @ mainThreadMessageService.ts:72
n.Class.derive._oncancel @ winjs.base.raw.js:1641
e._showMessage @ mainThreadMessageService.ts:42
e.$showMessage @ mainThreadMessageService.ts:36
e.invoke @ abstractThreadService.ts:41
e._invokeHandler @ rpcProtocol.ts:109
e._receiveOneMessage @ rpcProtocol.ts:96
(anonymous) @ rpcProtocol.ts:32
(anonymous) @ rpcProtocol.ts:157
e.invoke @ callbackList.ts:36
e.fire @ event.ts:123
(anonymous) @ ipc.net.ts:82
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560
messageService.ts:126 Git: Cannot read property 'resourceUri' of undefined
e.doShow @ messageService.ts:126
e.show @ messageService.ts:105
e._showMessage @ mainThreadMessageService.ts:72
n.Class.derive._oncancel @ winjs.base.raw.js:1641
e._showMessage @ mainThreadMessageService.ts:42
e.$showMessage @ mainThreadMessageService.ts:36
e.invoke @ abstractThreadService.ts:41
e._invokeHandler @ rpcProtocol.ts:109
e._receiveOneMessage @ rpcProtocol.ts:96
(anonymous) @ rpcProtocol.ts:32
(anonymous) @ rpcProtocol.ts:157
e.invoke @ callbackList.ts:36
e.fire @ event.ts:123
(anonymous) @ ipc.net.ts:82
emitOne @ events.js:96
emit @ events.js:191
readableAddChunk @ _stream_readable.js:178
Readable.push @ _stream_readable.js:136
onread @ net.js:560

console.ts:123 [Extension Host] ApplicationInsights:Sender [Object]0: Objectaddress: "40.77.226.250"code: "ECONNREFUSED"errno: "ECONNREFUSED"port: 443syscall: "connect"__proto__: Objectconstructor: function Object()hasOwnProperty: function hasOwnProperty()isPrototypeOf: function isPrototypeOf()propertyIsEnumerable: function propertyIsEnumerable()toLocaleString: function toLocaleString()toString: function toString()valueOf: function valueOf()__defineGetter__: function __defineGetter__()__defineSetter__: function __defineSetter__()__lookupGetter__: function __lookupGetter__()__lookupSetter__: function __lookupSetter__()get __proto__: function __proto__()set __proto__: function __proto__()length: 1__proto__: Array(0)concat: function concat()constructor: function Array()copyWithin: function copyWithin()entries: function entries()every: function every()fill: function fill()filter: function filter()find: function find()findIndex: function findIndex()forEach: function forEach()includes: function includes()indexOf: function indexOf()join: function join()keys: function keys()lastIndexOf: function lastIndexOf()length: 0map: function map()pop: function pop()push: function push()reduce: function reduce()reduceRight: function reduceRight()reverse: function reverse()shift: function shift()slice: function slice()some: function some()sort: function sort()splice: function splice()toLocaleString: function toLocaleString()toString: function toString()unshift: function unshift()Symbol(Symbol.iterator): function values()Symbol(Symbol.unscopables): Object__proto__: Object
t.log @ console.ts:123
t._logExtensionHostMessage @ extensionHost.ts:377
(anonymous) @ extensionHost.ts:202
emitTwo @ events.js:106
emit @ events.js:194
process.nextTick @ internal/child_process.js:766
_combinedTickCallback @ internal/process/next_tick.js:73
_tickCallback @ internal/process/next_tick.js:104

Faced the same issue on below enviornment:-

  • Mac OS - 10.12.6

  • VS code - Version 1.15.1 (1.15.1)

Steps:- Made changes to launch.json file but on discarding the changes its showing the error.

vscodeerror

OK GUYS! I got it, finally.

homer

Steps:

  1. Have 4 unstaged files: file1.txt, file2.txt, file3.txt, file4.txt.
  2. In the terminal, type git add file1.txt file3.txt
  3. Using the UI, stage file2.txt then unstage it. Repeat this 5 more times.
  4. Try clicking on file4.txt or any of its actions.

spongebob

Keep reading for a _postmortem_ analysis.


Here's where the bug is:

https://github.com/Microsoft/vscode/blob/0a42516de80d3141955114678b5736c5d124f796/src/vs/workbench/api/node/extHostSCM.ts#L265

We're basically dealing with a list of changes, sorted by the occurring index in the original sequence, and applying the same changes into a another list. This, of course, is a problem if the difference between the number of inserted elements is different than the number of deleted elements in that change, since the index positions for the following changes will all be wrong. The usual way to do this is to reverse the list of changes and apply them in that order. We do this in the main thread:

https://github.com/Microsoft/vscode/blob/0a42516de80d3141955114678b5736c5d124f796/src/vs/workbench/api/electron-browser/mainThreadSCM.ts#L179

But we overlooked doing the same when dealing with the _handlesSnapshot array.

Combine that with the fact that we only really dispose these guys 10 times after a resource group was effectively modified (that's why step 3 of the repro steps needs to be repeated 5 times), this bug proved to be a very elusive one.

lesson


I'll fix the order of handling these splices. I'll also remove the 10 generations before disposing... we can deal with that in some other way.

Should this error be gone in the most recently shipped version? (I'm not using the insiders build) I just got it.

git tag --contains 9752f3c returns empty... so: no.

This fix is already out in Insiders but will come in the next Stable (1.19.0).

Any idea when Stable v1.19.0 will be released? I'm seeing this error often and it's beginning to get annoying. :)

Should be released in the next one or two weeks

I have just had this happen when staging multiple files, I followed some advice seen above, changed folder, came back to project and all is well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sirius1024 picture sirius1024  路  3Comments

lukehoban picture lukehoban  路  3Comments

shanalikhan picture shanalikhan  路  3Comments

vsccarl picture vsccarl  路  3Comments

v-pavanp picture v-pavanp  路  3Comments