eclipse-theia/theia

SCANOSS does not work in built Theia IDE

JonasHelming opened this issue · 10 comments

  1. Go to settings => AI Features => SCANOSS => Turn to automatic or manual
  2. generate some code in the chat
    result:
    image

for details, see: #14643 (comment)

I'm not sure why an update to 3.0 would fix the problem, though: is the new mechanism for checking the class name more robust against name mangling, @sdirix ?

sdirix commented

@tsmaeder Yes, node-fetch uses a more robust way of checking their instances starting with version >= 3

However fixing this issue via resolutions has some downsides:

Therefore I suggest to adjust the webpack generator slightly, see #14650

To get rid of this workaround later we need to either

  • encourage / support scanoss to migrate to node-fetch v3 and replace form-data usage, AND/OR
  • encourage / support node-fetch to backport their improved checks to version v2

Note that the @theia/ai-openai and @theia/ai-anthropic also have a dependency to node-fetch v2. However during regular use I was not able to trigger the error with them so we seemingly avoid the problematic flow.

sdirix commented

Note that to fix the Theia IDE we also need PR eclipse-theia/theia-ide#434 as we already override the TerserPlugin there.

@sdirix I tried your fix, but it didn't work for me (see comment in the PR). To double-check, I tried to use the feature when doing a normal (development) build from master. But that does not work either form me. When I click on the "ScanOSS" button in the browser version, I get

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '0')
[rpc-message-encoder.ts:184:105](webpack:///packages/core/src/common/message-rpc/rpc-message-encoder.ts?)
    scanOSSClicked http://localhost:3000/packages_ai-scanoss_lib_browser_ai-scanoss-frontend-module_js.js:102
    AsyncFunctionThrow self-hosted:804
    (Async: async)
    callCallback http://localhost:3000/bundle.js:272952
    invokeGuardedCallbackDev http://localhost:3000/bundle.js:273001
    invokeGuardedCallback http://localhost:3000/bundle.js:273065
    invokeGuardedCallbackAndCatchFirstError http://localhost:3000/bundle.js:273079
    executeDispatch http://localhost:3000/bundle.js:277829
    processDispatchQueueItemsInOrder http://localhost:3000/bundle.js:277861
    processDispatchQueue http://localhost:3000/bundle.js:277874
    dispatchEventsForPlugins http://localhost:3000/bundle.js:277885
    dispatchEventForPluginEventSystem http://localhost:3000/bundle.js:278076
    batchedUpdates$1 http://localhost:3000/bundle.js:294962
    batchedUpdates http://localhost:3000/bundle.js:272779
    dispatchEventForPluginEventSystem http://localhost:3000/bundle.js:278075
    dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay http://localhost:3000/bundle.js:275253
    dispatchEvent http://localhost:3000/bundle.js:275245
    dispatchDiscreteEvent http://localhost:3000/bundle.js:275218
    (Async: EventListener.handleEvent)
    addEventBubbleListener http://localhost:3000/bundle.js:275475
    addTrappedEventListener http://localhost:3000/bundle.js:277979
    listenToNativeEvent http://localhost:3000/bundle.js:277917
    listenToAllSupportedEvents http://localhost:3000/bundle.js:277928
    forEach self-hosted:4281
    listenToAllSupportedEvents http://localhost:3000/bundle.js:277923
    createRoot http://localhost:3000/bundle.js:298208
    createRoot$1 http://localhost:3000/bundle.js:298638
    createRoot http://localhost:3000/bundle.js:298728
    ReactWidget http://localhost:3000/bundle.js:345363
    TreeWidget http://localhost:3000/bundle.js:341217
    ChatViewTreeWidget http://localhost:3000/packages_ai-chat-ui_lib_browser_chat-tree-view_chat-view-tree-widget_js.js:254
    createInstanceWithInjections http://localhost:3000/bundle.js:247023
    _createInstance http://localhost:3000/bundle.js:247013
    resolveInstance http://localhost:3000/bundle.js:247106
    _getResolvedFromBinding http://localhost:3000/bundle.js:247245
    _resolveBinding http://localhost:3000/bundle.js:247263
    _resolveInScope http://localhost:3000/bundle.js:247257
    _resolveBinding http://localhost:3000/bundle.js:247262
    _resolveRequest http://localhost:3000/bundle.js:247220
    resolve http://localhost:3000/bundle.js:247366
    Container http://localhost:3000/bundle.js:245935
    _get http://localhost:3000/bundle.js:245903
    _getButThrowIfAsync http://localhost:3000/bundle.js:245906
    get http://localhost:3000/bundle.js:245655
    createChatViewTreeWidget http://localhost:3000/packages_ai-chat-ui_lib_browser_ai-chat-ui-frontend-module_js.js:624
    default http://localhost:3000/packages_ai-chat-ui_lib_browser_ai-chat-ui-frontend-module_js.js:229
    _resolveFactoryFromBinding http://localhost:3000/bundle.js:247227
    tryAndThrowErrorIfStackOverflow http://localhost:3000/bundle.js:248235
    _resolveFactoryFromBinding http://localhost:3000/bundle.js:247226

in the browser log.

sdirix commented

Never saw this error. I will try to reproduce this on a Windows machine

Same error in Electron.

Maybe related, I get these errors when I type into the AI chat:

errors.ts:30 Uncaught Error: There are no document for untitled:/Untitled-1aichatviewlanguage

Error: There are no document for untitled:/Untitled-1aichatviewlanguage
    at CodeActionAdapter.provideCodeAction (/C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\node_modules_theia_monaco-editor-core_esm_vs_base_common_sync_recursive-packages_core_shared_-54ebfc.js:8138:35)
    at /C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\node_modules_theia_monaco-editor-core_esm_vs_base_common_sync_recursive-packages_core_shared_-54ebfc.js:7655:93
    at LanguagesExtImpl.withAdapter (/C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\node_modules_theia_monaco-editor-core_esm_vs_base_common_sync_recursive-packages_core_shared_-54ebfc.js:7398:20)
    at LanguagesExtImpl.$provideCodeActions (/C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\node_modules_theia_monaco-editor-core_esm_vs_base_common_sync_recursive-packages_core_shared_-54ebfc.js:7655:21)
    at RPCProtocolImpl.handleRequest (/C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\packages_plugin-ext_lib_common_plugin-api-rpc_js.js:2081:31)
    at RpcProtocol.requestHandler (/C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\packages_plugin-ext_lib_common_plugin-api-rpc_js.js:2063:96)
    at RpcProtocol.handleRequest (/C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\packages_core_lib_common_index_js-node_modules_vscode-languageserver-types_lib_umd_sync_recursive.js:3625:39)
    at RpcProtocol.handleMessage (/C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\packages_core_lib_common_index_js-node_modules_vscode-languageserver-types_lib_umd_sync_recursive.js:3512:26)
    at /C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\packages_core_lib_common_index_js-node_modules_vscode-languageserver-types_lib_umd_sync_recursive.js:3498:66
    at /C:/Users/thomas/code/theia/theia3/examples/electron/lib/frontend/C:\Users\thomas\code\theia\theia3\examples\electron\lib\backend\packages_core_lib_common_index_js-node_modules_vscode-languageserver-types_lib_umd_sync_recursive.js:1414:69
    at errors.ts:30:12
sdirix commented

I was able to reproduce the error in Windows. I'll investigate.

Maybe related, I get these errors when I type into the AI chat:

I don't think this is related. This seemingly comes in via a VS Code extension as I don't see this error when running Theia without plugins.

sdirix commented

The Windows issue was fixed here: #14653