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

SCANOSS does not work in built Theia IDE #14648

Closed
JonasHelming opened this issue Dec 18, 2024 · 10 comments · Fixed by #14650 or #14653
Closed

SCANOSS does not work in built Theia IDE #14648

JonasHelming opened this issue Dec 18, 2024 · 10 comments · Fixed by #14650 or #14653
Labels

Comments

@JonasHelming
Copy link
Contributor

JonasHelming commented Dec 18, 2024

  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)

@tsmaeder
Copy link
Contributor

See also #14643 (comment)

@tsmaeder
Copy link
Contributor

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 added a commit to eclipsesource/theia that referenced this issue Dec 18, 2024
scanoss depends on node-fetch <3. node-fetch in that version fails their
instance checks, as it relies on constructor/class names which are
removed by the backend bundling.

Adjusts the generated webpack configuration to keep the class name for
AbortSignal as this is the name checked in node-fetch.

fixes: eclipse-theia#14648
sdirix added a commit to eclipsesource/theia that referenced this issue Dec 18, 2024
scanoss depends on node-fetch <3. node-fetch in that version fails their
instance checks, as it relies on constructor/class names which are
removed by the backend bundling.

Adjusts the generated webpack configuration to keep the class name for
AbortSignal as this is the name checked in node-fetch.

fixes eclipse-theia#14648
@sdirix
Copy link
Member

sdirix commented Dec 18, 2024

@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
Copy link
Member

sdirix commented Dec 18, 2024

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

@tsmaeder
Copy link
Contributor

@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
Copy link
Member

sdirix commented Dec 19, 2024

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

@tsmaeder
Copy link
Contributor

Same error in Electron.

@tsmaeder
Copy link
Contributor

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
Copy link
Member

sdirix commented Dec 19, 2024

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 added a commit to eclipsesource/theia that referenced this issue Dec 19, 2024
On Windows, the scanoss library returns its results in a different
shape than on the other platforms.  We now anticipate this behavior.

fixes eclipse-theia#14648
@sdirix sdirix closed this as completed in 61f6b19 Dec 19, 2024
sdirix added a commit that referenced this issue Dec 19, 2024
scanoss depends on node-fetch <3. node-fetch in that version fails their
instance checks, as it relies on constructor/class names which are
removed by the backend bundling.

Adjusts the generated webpack configuration to keep the class name for
AbortSignal as this is the name checked in node-fetch.

fixes #14648
jfaltermeier pushed a commit that referenced this issue Dec 19, 2024
On Windows, the scanoss library returns its results in a different
shape than on the other platforms.  We now anticipate this behavior.

fixes #14648
jfaltermeier pushed a commit that referenced this issue Dec 19, 2024
scanoss depends on node-fetch <3. node-fetch in that version fails their
instance checks, as it relies on constructor/class names which are
removed by the backend bundling.

Adjusts the generated webpack configuration to keep the class name for
AbortSignal as this is the name checked in node-fetch.

fixes #14648
@sdirix
Copy link
Member

sdirix commented Dec 19, 2024

The Windows issue was fixed here: #14653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants