Skip to main content

Posts

Showing posts with the label Electron

Fixing 'node-gyp' Rebuild Errors with Better-SQLite3 in Electron

  If you are integrating   better-sqlite3   into an Electron application, you have likely encountered the following stack trace upon starting your application: Error: The module '\\?\C:\path\to\app\node_modules\better-sqlite3\build\Release\better_sqlite3.node' was compiled against a different Node.js version using NODE_MODULE_VERSION 115. This version of Node.js requires NODE_MODULE_VERSION 121. Please try re-compiling or re-installing the module (for instance, using npm rebuild or npm install). This is the quintessential native module ABI mismatch. It stops production builds and local development servers dead in their tracks. This post details why this occurs at a binary level and provides an automated, infrastructure-as-code solution to fix it permanently. The Root Cause: ABI and V8 Divergence Node.js allows developers to write add-ons in C++ (like  better-sqlite3 ). When you run  npm install , the  node-gyp  build tool compiles this C++ code into ...

Electron Performance Guide: Offloading CPU Tasks to Worker Threads

  The Blocking UI Problem There is no quicker way to destroy user trust than a frozen application window. In Electron, the most common performance bottleneck stems from a misunderstanding of the process model. You have a complex image manipulation algorithm, a massive CSV parser, or a cryptographic function. You run it in the Renderer process. Suddenly, hover effects stop working, the window cannot be dragged, and the OS prompts the user to "Force Quit" the application. This happens because the Renderer process is responsible for both executing your JavaScript logic and painting the UI. Both share the same main thread in the V8 engine. The Root Cause: The V8 Event Loop To fix this, you must understand  why   async/await  is not a magic bullet. JavaScript is single-threaded. When you use  Promise  or  async/await , you are performing  asynchronous  operations, but not necessarily  parallel  ones. If an operation is I/O bound (waiting...