Buffer not defined in Webworker

I’m trying to fix front end plugins (https://github.com/eclipse-theia/theia/issues/6601) and have a solution that works in Firefox and Chromium, but not in Electron.
The problem is that “Buffer” is not defined in the Worker that runs the plugins (see worker-main.ts). In the main browser thread, “Buffer” is available globally. The dependency come from rpc-protocol.ts importing stuff (CancellationToken) from languageserver-node.
Unfortunately, I have no idea how to fix this. Any clues?

Set the nodeIntegrationInWorker to true here. (I did not try it though, but should help.)

When you’re submitting the PR (thank you for your help :medal_sports:), you can enable the nodeIntegrationInWorker in a separate commit. I hope this helps!

Hmh…thx for the pointer, but it seems we turned that option off for security reasons, so I don’t think we should merge that, right? Do you know why the polyfill gets applied to the renderer, but not the worker?

No, we did not. Node integration for the renderer and the worker was enabled by default with electron 4.x. Then we bumped up to 9.x where this is disabled by default.

Do you know why the polyfill gets applied to the renderer

Yes. webpack makes sure it is there for target: web. It’s different for the electron target.

Related: https://gist.github.com/earksiinni/053470a04defc6d7dfaacd5e5a073b15

“InWorker” was the part I was missing.