Closed jrieken closed 9 months ago
@aiday-mar do you know if this is related to https://github.com/microsoft/vscode/issues/201812?
I looked at the file codeActionController
and the stack trace refers to the method onFocus
and that the diagnostic
inside of diagnostic.startLineNumber
appears to be undefined. I think this is probably not linked to https://github.com/microsoft/vscode/issues/201812. It looks however that the diagnostics array is empty, and the code is trying to access the first non-existent diagnostic.
@aiday-mar yep I see that now! looks like some flow from the light bulb widget exposed a bug with onFocus
which i wrote a few months ago š taking a look now ~
I have encountered this today when running code-oss. Find the unminified trace below.
I believe the flaw is accessing the array of diagnostics because there is no check that it has any elements. Hence it continues with undefined
2024-01-24 10:23:53.268 [error] Cannot read properties of undefined (reading 'startLineNumber'): TypeError: Cannot read properties of undefined (reading 'startLineNumber')
at Object.onFocus (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/editor/contrib/codeAction/browser/codeActionController.js:209:40)
at ActionList.onFocus (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actionWidget/browser/actionList.js:235:37)
at UniqueContainer.value (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actionWidget/browser/actionList.js:149:67)
at Emitter._deliver (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:870:26)
at Emitter._deliverQueue (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:881:22)
at Emitter.fire (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:904:22)
at vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:98:93
at UniqueContainer.value (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:1206:34)
at Emitter._deliver (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:870:26)
at Emitter.fire (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:899:22)
at Trait._set (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/browser/ui/list/listWidget.js:122:28)
at Trait.set (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/browser/ui/list/listWidget.js:113:25)
at List.setFocus (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/browser/ui/list/listWidget.js:1302:24)
at List.focusNext (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/browser/ui/list/listWidget.js:1311:22)
at ActionList.focusNext (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actionWidget/browser/actionList.js:201:24)
at ActionWidgetService.focusNext (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actionWidget/browser/actionWidget.js:52:32)
at Action2.run (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actionWidget/browser/actionWidget.js:185:31)
at handler (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actions/common/actions.js:389:52)
at InstantiationService.invokeFunction (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/instantiation/common/instantiationService.js:46:24)
at CommandService._tryExecuteCommand (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/workbench/services/commands/common/commandService.js:81:59)
at CommandService.executeCommand (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/workbench/services/commands/common/commandService.js:50:33)
at WorkbenchKeybindingService._doDispatch (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/keybinding/common/abstractKeybindingService.js:259:54)
at WorkbenchKeybindingService._dispatch (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/keybinding/common/abstractKeybindingService.js:143:25)
at vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/workbench/services/keybinding/browser/keybindingService.js:192:51
2024-01-24 10:23:56.221 [error] Cannot read properties of undefined (reading 'startLineNumber'): TypeError: Cannot read properties of undefined (reading 'startLineNumber')
at Object.onFocus (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/editor/contrib/codeAction/browser/codeActionController.js:209:40)
at ActionList.onFocus (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actionWidget/browser/actionList.js:235:37)
at UniqueContainer.value (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actionWidget/browser/actionList.js:149:67)
at Emitter._deliver (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:870:26)
at Emitter._deliverQueue (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:881:22)
at Emitter.fire (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:904:22)
at vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:98:93
at UniqueContainer.value (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:1206:34)
at Emitter._deliver (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:870:26)
at Emitter.fire (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/common/event.js:899:22)
at Trait._set (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/browser/ui/list/listWidget.js:122:28)
at Trait.set (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/browser/ui/list/listWidget.js:113:25)
at List.setFocus (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/base/browser/ui/list/listWidget.js:1302:24)
at ActionList.onListHover (vscode-file://vscode-app/Users/jrieken/Code/vscode/out/vs/platform/actionWidget/browser/actionList.js:248:24)
yep, realized that the fix I pushed last week was not an actual fix š¢
this PR should do it, checking that the array is not empty.
just for personal reference, I am curious which code action was giving this error? I wasn't able to see the error on any of the move to
actions or copilot actions
just for personal reference, I am curious which code action was giving this error? I wasn't able to see the error on any of the move to actions or copilot actions
Hard to say but since I am seeing this with insiders and code-oss means it must be an extension that is installed in both and that's either TS or copilot.
@jrieken gotcha, that makes sense. iirc, it could be both, since code actions from the lightbulb, when there are no errors in the line, shouldn't have diagnostics attached to them.
either way, if you could verify the fix that would be great š„
Change looks good, added verified
if (diagnostic.startLineNumber && diagnostic.startColumn) {
I think in some parts you are a bit over-cautious. Like above you can assume that startLineNumber and startColumn are always defined. Otherwise it would be a bug with somewhere upstream that you shouldn't swallow. The fine line of failing fast and continuing gracefully ;-)
makes sense! that was something I added in the first PR quickly since I thought that would fix the initial issue, removing now for debt š