1.34.0 / Linux: all webviews fail - webviewProtocolProvider sends the whole pooled ArrayBuffer, service-worker.js fails to parse

Environment

  • Qoder IDE 1.34.0 (base VS Code 1.106.3, commit b98cae71697a1f5cb03ec68386a98dc2f39827aa)
  • Arch Linux, kernel 7.2.10, Wayland session (X11 also affected)
  • Runs on system Electron: electron42 42.11.14-2 (Chromium 148.0.7778.280), installed via AUR package qoder-ide-bin 1.34.0-1
  • The app’s product.json declares “electron”: “42.2.0”
  • Affected: every webview (seepine.md-editor, Markdown preview, any extension webview panel)

Symptom

Error loading webview: Error: Could not register service worker: TypeError: Failed to register a ServiceWorker for scope (‘vscode-webview:///’) with script (‘vscode-webview:///service-worker.js?v=4&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&remoteAuthority=’): ServiceWorker script evaluation failed.

Clearing Service Worker/, Code Cache/, Cache/, GPUCache/, CachedData/ and restarting does not help. A brand-new profile reproduces it as soon as a webview loads.

Root cause (confirmed with Chromium logs)

Launching with --enable-logging=stderr --v=1 shows the real reason:

[INFO:CONSOLE:1] "Uncaught SyntaxError: Unexpected token ':'",
  source: vscode-webview://<uuid>/service-worker.js?v=4&... (1)

The response body is not the 7031-byte service-worker.js - it is the whole backing ArrayBuffer of the VSBuffer, which can be a view into Node’s 64 KiB slab pool. Chromium therefore receives the script plus trailing garbage bytes and the worker script fails to parse.

out/main.js, webviewProtocolProvider.handleWebviewRequest:

o = await this._fileService.readFile(s);
return new Response(o.value.buffer.buffer, { headers: { ... } });   // <-- whole slab, not the file bytes

Minimal reproduction (same electron42 binary, no Qoder involved)

Register the real vs/workbench/contrib/webview/browser/pre/service-worker.js through a privileged vscode-webview scheme plus --service-worker-schemes=vscode-webview:

  • body = exact-size ArrayBuffer (content.buffer, 7031 bytes) → register() OK
  • body = 8 KiB pooled slab containing the content + junk (slab.buffer) → “ServiceWorker script evaluation failed”, identical message

So the Electron build, the scheme privileges and the script itself are fine; only the response length is wrong.

Suggested fix

- return new Response(o.value.buffer.buffer, { headers: { ... } });
+ const b = o.value.buffer;
+ return new Response(b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength), { headers: { ... } });

Note the other .buffer.buffer usage in main.js (writeImage) already passes byteOffset/byteLength; only this handler misses it.

Why it shows up on Arch

The AUR package runs the official bundle on system Electron 42.11.14 while the app declares electron 42.2.0. Whether fileService.readFile() returns a pooled view seems to depend on that combination; the official bundled build may not hit it, but the handler is unsafe in every build.

Workaround for affected users

Patch that one line in /usr/lib/qoder-ide/out/main.js (keep a backup, validate with node --check), then fully quit and restart Qoder. The change has to be re-applied after each package update.