I'm not sure how to reproduce this, but when I open VsCode. Running 'index workspace' doesn't trigger the error again.
Note how the TypeError shows up twice.
```
[Info - 08:02:52] Initialising
[Info - 08:02:52] Reading state from c:\Users\username\AppData\Roaming\Code\User\workspaceStorage\89b4fd672eb5a6428e92e5befb636c62\bmewburn.vscode-intelephense-client\1b262304.
[Info - 08:02:53] Initialised in 511 ms
[Info - 08:02:53] Intelephense 1.0.8
[Error - 08:02:53] TypeError: Cannot read property 'get' of undefined
at t.DefinitionStore.find (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:58542)
at Function.fromName (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:48256)
at t.TypeFactory.fromName (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:45156)
at c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:323926
at C (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:324360)
at c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:303371
at n (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:303418)
at t (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:297797)
at n (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:305757)
at t (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:297797)
[Error - 08:02:53] TypeError: Cannot read property 'get' of undefined
at t.DefinitionStore.find (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:58542)
at Function.fromName (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:48256)
at t.TypeFactory.fromName (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:45156)
at Y (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:328173)
at c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:319588
at C (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:319914)
at H (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:327275)
at c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:321434
at C (c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:321865)
at c:\Users\username.vscode\extensions\bmewburn.vscode-intelephense-client-1.0.8\node_modulesintelephense\libintelephense.js:39:312413
The issue seems to be related to a call to the function below. I just now noticed the docblock is wrong, specifying the returntype to be a class, while false can be returned.
/**
* @throws Exception
* @return AppStateRoot
*/
function AppState() {
if( !isset($GLOBALS[ACTIVE_APPSTATE_VARIABLE_NAME]) ) {
if( !func_num_args() || func_get_arg(0) ) {
throw new Exception("Appstate not set");
}
return false;
}
return $GLOBALS[ACTIVE_APPSTATE_VARIABLE_NAME];
}
On further inspection it might also be a the following typehint. However the issue just suddenly stopped happening.
I had distilled the problem down to a specific file. If I edited that file (which I cannot share), the error happened. After emptying out the file line by line, I found that removing this line of docblock from a method seemed to help.
* @param int|MyGlobalNamespaceClass|null $myParam
After saving, closing VSCode and then reverting the contents of the file to original, The error didn't come back anymore.
Hey there!
I got the same error message, but i was unable to reproduce it by deleting just coded lines, as you did.
Maybe you can try the same as I did: Just delete the cache folder.
You can find it here: [Info - 08:02:52] Reading state from c:\Users\username\AppData\Roaming\Code\User\workspaceStorage\89b4fd672eb5a6428e92e5befb636c62\bmewburn.vscode-intelephense-client\1b262304.
Just delete the folder, rerun the index (that should happen automatically after restarting vscode)
After that everything worked fine again. (Also im not sure if this is exactly the same problem, but the error message is the same)
Somehow the definition index is retaining references to a deleted file. Unsure how this is happening. Could be happening when opening and closing a file from outside the workspace, deleting a file/folder, adding/removing folders or git checkout. I think what is being typed at the time of the error is not the cause, just a symptom.
@Mr-JoerT after you reindex does it occur again?
@bmewburn No. After my trick with emptying the file and restarting VS-Code the issue had not resurfaced. If it ever does, should I backup my cache dir or something so we can analyse this further?
@Mr-JoerT , that's a good idea. If you dont mind sending me the cache data in the future it may help debug this.
Somehow the definition index is retaining references to a deleted file. Unsure how this is happening. Could be happening when opening and closing a file from outside the workspace, deleting a file/folder, adding/removing folders or git checkout. I think what is being typed at the time of the error is not the cause, just a symptom.
@Mr-JoerT after you reindex does it occur again?
Which file/folder to delete?This problem has been bothering me for a long time, thank you.
@niaiwomattt
For me there was one specific file that triggered this error when I edited it. I solved the issue by making the whole file empty. Saving. Closing VSCode. Starting it up again, and pasting the contents back into that file.
Probably Reindexing would work too.
@bmewburn indeed, it's a cache error. after removing all files in the cache, the error is gone. probably the best way to deal with this is to invalidate the cache if that error happens.
Most helpful comment
Hey there!
I got the same error message, but i was unable to reproduce it by deleting just coded lines, as you did.
Maybe you can try the same as I did: Just delete the cache folder.
You can find it here:
[Info - 08:02:52] Reading state from c:\Users\username\AppData\Roaming\Code\User\workspaceStorage\89b4fd672eb5a6428e92e5befb636c62\bmewburn.vscode-intelephense-client\1b262304.Just delete the folder, rerun the index (that should happen automatically after restarting vscode)
After that everything worked fine again. (Also im not sure if this is exactly the same problem, but the error message is the same)