getsentry / raven-node

A standalone (Node.js) client for Sentry
https://sentry.io/
BSD 2-Clause "Simplified" License
454 stars 135 forks source link

Using raven-node within an Electron renderer process #441

Open jlongster opened 6 years ago

jlongster commented 6 years ago

Electron has two type of processes, the main process which controls everything, and individual renderer processes which represent separate UI processes. The renderer process may have "node integration" enabled, meaning you have full access to node APIs.

You want to run as little JS on the main process as possible (see my post). Because of this, I'm running my entire backend in a hidden renderer process that I basically use as just a node process (there's zero UI and no usage of browser APIs). It's treated as a node program.

The problem is sentry really wants you to use raven-js in the renderer process. Running raven-node inside a renderer process that has full node integration doesn't work. And it doesn't work in a big way: it crashes electron. For some reason it crashes when trying to read the source files here: https://github.com/getsentry/raven-node/blob/2060d3cb0297fd3f3faa132a0f9151ca81dfabbb/lib/utils.js#L270, even though I can read those files fine if I do fs.readFile somewhere else in my code in the renderer process.

My files aren't sourcemapped, so by using raven-js, I won't get any source info in sentry. There's zero way for me to get it work. Since my files aren't sourcemapped, I can't upload a sourcemap. But since raven-node doesn't work, I have to use raven-js which expects sourcemaps.

Do you want to request a feature or report a bug? Sort of both

Has someone had this problem before? I could not find anything

(using latest version of raven-node)

jlongster commented 6 years ago

I found out another approach for running my node backend that may solve this. Supposedly you can fork the electron process which creates a standalone node process which is what I want, and would solve all the issues like this one (I could use raven-node like normal). I expect to hit issues but hopefully it works smoothly.