excalidraw / excalidraw-vscode

Excalidraw for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=pomdtr.excalidraw-editor
MIT License
454 stars 55 forks source link

bug: code-server + corporate proxy causing assertion failed error #141

Open lrstanley opened 3 months ago

lrstanley commented 3 months ago

We run code-server in Kubernetes (i.e. through a browser), however, most extensions work without issue. When using excalidraw 3.7.4, I am noticing that I cannot open any excalidraw file, and it throws errors in the browser console

(see buildHtmlForWebview in stack trace):

GET https://TRUNCATED/TRUNCATED, 401 (authenticationrequired)
readFile @ webWorkerFileSystemProvider.ts:21
(anonymous) @ fileService.ts:666
I @ fileService.ts:688
D @ fileService.ts:583
C @ fileService.ts:520
readFile @ fileService.ts:503
await in readFile (async)
$readFile @ mainThreadFileSystem.ts:99
S @ rpcProtocol.ts:458
Q @ rpcProtocol.ts:443
M @ rpcProtocol.ts:373
L @ rpcProtocol.ts:299
(anonymous) @ rpcProtocol.ts:161
y @ event.ts:1156
fire @ event.ts:1187
D.M.onmessage @ webWorkerExtensionHost.ts:215
log.ts:439   ERR Unknown (FileSystemError): authenticationrequired: Unknown (FileSystemError) (FileSystemError): Unknown (FileSystemError): authenticationrequired
    at w.e (../../../vs/workbench/api/worker/extensionHostWorker.js:100:7189)
    at Object.readFile (../../../vs/workbench/api/worker/extensionHostWorker.js:100:4463)
    at async D.buildHtmlForWebview (https://open-vsx.org/vscode/asset/pomdtr/excalidraw-editor/3.7.4/Microsoft.VisualStudio.Code.WebResources/extension/dist/extension.js#vscode-extension:3:13102)
    at async D.setupWebview (https://open-vsx.org/vscode/asset/pomdtr/excalidraw-editor/3.7.4/Microsoft.VisualStudio.Code.WebResources/extension/dist/extension.js#vscode-extension:3:11317)
    at async x.resolveCustomEditor (https://open-vsx.org/vscode/asset/pomdtr/excalidraw-editor/3.7.4/Microsoft.VisualStudio.Code.WebResources/extension/dist/extension.js#vscode-extension:3:8965)

Which looks to then cause this error:

Error: Assertion Failed: argument is undefined or null
    at d (types.ts:99:9)
    at l.resolve (customEditorInput.ts:340:36)
    at async a.setInput (webviewEditor.ts:153:3)
    at async n.S (editorPanes.ts:434:4)
    at async n.L (editorPanes.ts:254:34)
    at async n.openEditor (editorPanes.ts:131:11)
    at async editorGroupView.ts:1188:49
    at async u.value (explorerView.ts:526:6)

Looking at the code, it looks like this is the culprit:

https://github.com/excalidraw/excalidraw-vscode/blob/42253cd9b74a21c8de60433a6eef574f458483b4/extension/src/editor.ts#L346-L349

Is there a specific reason that it's configured to load the index.html directly from the extension repository (in my case, openvsx)?

I know the underlying reason for the authenticationrequired error, which is due to a corporate proxy (browser can't hit it, but code-server environment can, definitely understand that this is a niche issue).

Is there any way to bundle that index.html into the extension itself, so no external requests would be required?

code-server information:

code-server: v4.89.1
Code: 1.89.1
Commit: effc6e95b4ad1c5ac5f9083ec06663ba4a2e005c
Date: 2024-05-13T18:42:51.662Z (3 wks ago)
Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0
lrstanley commented 3 months ago

Looks like this is likely related to a few issues: https://github.com/excalidraw/excalidraw-vscode/issues/85 (maybe), https://github.com/coder/code-server/issues/6306.