Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Electron Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-electron-knowledge-patch)
---
name: electron-knowledge-patch
description: Electron
version: "45.5.0"
license: MIT
metadata:
author: Nevaberry
---
# Electron Knowledge Patch
Use this skill when upgrading Electron applications or working with preloads,
sessions, extensions, native windows, media capture, packaging, and diagnostics.
Read the relevant topic reference for complete conditions, platform differences,
examples, and version attribution.
## Reference index
| Reference | Topics |
| --- | --- |
| [Upgrades and runtime](references/upgrades-and-runtime.md) | Platform requirements, binary installation, native add-ons, snapshots, runtime flags, embedded engines |
| [Sessions, networking, and extensions](references/sessions-networking-and-extensions.md) | Preloads, service workers, extension APIs, requests, protocols, authentication, cookies, storage |
| [Processes and diagnostics](references/processes-diagnostics-and-runtime.md) | Renderer stacks, frames, tracing, utility processes, crash reporting, memory |
| [Graphics, media, and NativeImage](references/graphics-media-and-native-image.md) | Display capture, shared textures, offscreen rendering, image color, printing, PDFs |
| [Notifications, security, and packaging](references/notifications-security-and-packaging.md) | ASAR, updates, notifications, permissions, devices, WebAuthn, safe storage, content protection |
| [Windows, input, and platform UI](references/windows-input-and-platform-ui.md) | Clipboard, popups, window state, menus, shortcuts, dialogs, title bars, accessibility |
## Breaking changes and deprecations
### Sandboxed preloads and extension frames
Electron 45 removes the `events`, `timers`, and `url` modules and the `Buffer`,
`setImmediate`, and `clearImmediate` globals from sandboxed preloads. Bundle
polyfills for the APIs the preload uses.
In Electron 45, a `chrome-extension://` document gets window and session preload
scripts when it is a top-level frame or runs inside the DevTools frontend.
Extension frames embedded in ordinary pages follow `nodeIntegrationInSubFrames`.
### Clipboard migration
Electron 44 removes direct renderer access to the `clipboard` module, including
in unsandboxed renderers. Use `navigator.clipboard` for standard renderer
clipboard operations. The earlier deprecation guidance moves Electron clipboard
calls to a preload and exposes needed operations through `contextBridge`.
In Electron 44, await `clipboard.readText()`, `clipboard.writeText()`, and
`clipboard.has(mimeType)`. Write related formats atomically in one
`clipboard.write()` call. Replace `availableFormats()` with `clipboard.read()`
and each item's `types`; read a format with `getType(mimeType)`, usually as a `Blob`.
The window reference includes format migration, bookmarks, native file references,
and the Linux `clipboard.selection` namespace.
### Safe storage and native heap tracing
Electron 45 deprecates `safeStorage.isEncryptionAvailable()`, `encryptString()`,
and `decryptString()` ahead of removal in 46. Use `isAsyncEncryptionAvailable()`,
`encryptStringAsync()`, and `decryptStringAsync()` from the same module.
Use `decryptStringAsync()` for existing ciphertext too.
Electron 45 removes `contentTracing.enableHeapProfiling()`. Pass
`nativeHeapProfiling` to `contentTracing.startRecording()` for native heap
profiling during the trace, and read the output as Perfetto protobuf.
### ASAR descriptors and packaging
In Electron 45, `fs.open()`, `fs.openSync()`, and `fs.promises.open()` on a packed
file return an archive-entry descriptor usable by Node's `fs` methods. Raw
descriptor consumers, including native add-ons and child-process stdio, fail
with `EBADF` and need a file outside the archive. Write-mode opens and
`fs.fchmod()`, `fs.fchown()`, and `fs.futimes()` fail with `EACCES`.
Electron 44 statically links ANGLE on all platforms. Remove packaging references
to separate `libEGL` and `libGLESv2` libraries and steps that swapped ANGLE builds.
### Popup sandbox and worker inheritance
In Electron 45, a `window.open()` child with a different sandbox setting runs in
its own renderer process and loses its opener relationship. To preserve it when
the opener is deliberately unsandboxed, set
`overrideBrowserWindowOptions.webPreferences.sandbox: false` in the
`setWindowOpenHandler()` result.
In Electron 42.11.3, 43.7.0, and 44.3.0, `nodeIntegrationInWorker` applies only
when the creating frame itself has Node.js integration. Subframes that need
Node-enabled workers also require `nodeIntegrationInSubFrames`.
### Capture and storage permissions
In Electron 45, screen, window, and tab capture requests arrive at
`session.setPermissionRequestHandler()` as `display-capture`. Update handlers
that only allow `media` to handle `display-capture` for permitted screen sharing.
Electron 45 disables `document.requestStorageAccessFor()` by default. To restore
it temporarily, set `webPreferences.enableBlinkFeatures` to
`'RequestStorageAccessFor'`.
### Platform requirements and installation
Electron 44 requires macOS 13 (Ventura) or later. Electron 43 is the last series
with prebuilt Windows x86 and Linux ARM binaries; support ends in January 2027.
The upgrade reference covers companion artifacts and download naming changes.
From Electron 42, the npm package downloads its binary into `node_modules` when
its CLI first runs. Package installation supports `--ignore-scripts`, and
`ELECTRON_SKIP_BINARY_DOWNLOAD` has been removed. Fetch the binary during setup:
```sh
npm install --save-dev --ignore-scripts electron
npx install-electron
```
### Linux window and dialog behavior
Electron 38 defaults to `--ozone-platform=auto`, selecting native Wayland in a
Wayland session. Replace removed `ELECTRON_OZONE_PLATFORM_HINT` with explicit
`--ozone-platform=x11` if X11 compatibility through Xwayland is needed.
Electron defaults to GTK 4 on GNOME from Electron 36. If a dependency loads GTK 3
or GTK 2 into the same process, select the matching version with
`--gtk-version=3` or `--gtk-version=2`.
Electron 43 removes `showHiddenFiles` support on Linux. File dialogs also stop
restoring the last-used directory when `defaultPath` is omitted: save the
directory after a successful selection and pass it as `defaultPath` next time.
### API and event migrations
- Replace `setPreloads` and `getPreloads` with `registerPreloadScript`,
`unregisterPreloadScript`, and `getPreloadScripts`.
- Move extension methods and events from `session` to `session.extensions`.
- An empty `WebRequestFilter.urls` array no longer matches every URL;
use `urls: ['<all_urls>']` for an all-URL listener.
- `session.clearStorageData()` no longer accepts `quotas` in Electron 42.
- Replace deprecated `image.getBitmap()` with `image.toBitmap()`;
both return newly allocated bitmap copies.
- Replace renderer `webFrame.routingId` and `webFrame.findFrameByRoutingId(routingId)`
with `webFrame.frameToken` and `webFrame.findFrameByToken(frameToken)`.
- Read frame-valued event properties such as `event.senderFrame` synchronously
at listener entry; after an `await`, a cross-origin navigation can make them `null`.
## Common feature workflows
### Register and filter preloads
Set `type: 'service-worker'` to target the service-worker preload realm,
including Manifest V3 extension workers. Use `ipcRenderer` there with the
corresponding worker's `ServiceWorkerMain.ipc` in the main process.
Electron 44.10.0 and 45.1.0 add `matches`, `excludeMatches`, `includeGlobs`,
`excludeGlobs`, and `matchOriginAsFallback` to `session.registerPreloadScript()`.
Use `getInfoFromVersionID(versionId)` for worker metadata,
`getWorkerFromVersionID(versionId)` for a `ServiceWorkerMain`, and
`startWorkerForScope(scope)` to start a stopped worker on `session.serviceWorkers`.
### Inspect requests and extension access
Use `excludeUrls` to omit URLs that otherwise match a `webRequest` filter's
`urls`. Electron 43.7.0 and 44.4.0 expose `initiatorOrigin` on request details
and protocol handler requests; downloads expose `DownloadItem.getInitiatorOrigin()`.
Electron 44.6.0 and 45.0.0 add experimental `protocol.registerSource()` for
serving a custom scheme directly from directories on disk. In 44.10.0 and
45.1.0, these schemes follow the same fetch rules as `protocol.handle()` schemes.
`chrome.tabs.query()` exposes a tab's `url` and `title` only with the `tabs`
permission or host access for that tab in Electron 42.11.1, 43.5.1, and 44.1.1.
Handle missing fields for extensions that can run with limited permissions.
### Diagnose renderers and utility processes
When a renderer emits `unresponsive`, call
`webContents.mainFrame.collectJavaScriptCallStack()`. Enable
`DocumentPolicyIncludeJSCallStacksInCrashReports` at startup and serve the target
document with `Document-Policy: include-js-call-stacks-in-crash-reports`.
The process reference contains the startup and event-handler example.
Utility-process unhandled rejections emit a warning and leave the process running.
An `unhandledRejection` handler can restore exit-on-rejection behavior.
`process.exit()` terminates a utility process synchronously; pending output can
be lost. The process reference gives the versions that deliver already-written
piped output and messages sent immediately before exit.
### Capture, render, and print
For macOS desktop audio capture on macOS 14.2 and later, add
`NSAudioCaptureUsageDescription` to the app's `Info.plist`. Electron 39 uses
CoreAudio Tap by default and returns a dead stream without an error or warning
if the key is missing.
Offscreen rendering defaults to device scale factor `1.0` from Electron 42,
independent of the primary display. Set `webPreferences.offscreen.deviceScaleFactor`
to control rendered pixel size. The graphics reference covers shared-texture
formats, payloads, imports, and capture scaling.
Call `printToPDF()` on the target `WebFrameMain` from the main process to create
a PDF buffer for that frame in Electron 42.9.0 and 43.4.0.
### Integrate native notifications and accessibility
The macOS switch to `UNNotification` in Electron 42 requires a code-signed app;
an unsigned app's notification emits `failed` on its `Notification` instance.
On Windows, `Notification.handleActivation(callback)` receives clicks, replies,
and action-button activations, including when a notification launches the app.
Read `nativeTheme.shouldUseDarkColorsForSystemIntegratedUI` for system-integrated
UI's dark-mode preference independently of the app's theme selection.
In Electron 45.5.0,
`systemPreferences.getAnimationSettings().prefersAnimatedImagesStartPaused`
reflects macOS's **Auto-play animated images** setting.