Skip to content

Instantly share code, notes, and snippets.

@AlexSchwabauer
Last active May 13, 2024 11:23
Show Gist options
  • Save AlexSchwabauer/1de7f7d737d7826a53e6429045dc77c3 to your computer and use it in GitHub Desktop.
Save AlexSchwabauer/1de7f7d737d7826a53e6429045dc77c3 to your computer and use it in GitHub Desktop.
Promise from desktopCapturer.getSources does not resolve without permission grant
const {
app,
BrowserWindow,
desktopCapturer,
} = require("electron");
app.whenReady().then(() => {
let promise;
const interval = setInterval(() => {
console.log("Promise state", promise);
}, 1000);
promise = desktopCapturer.getSources({ types: ["screen"] })
.finally(() => {
clearInterval(interval);
console.info("CAPTURER RESOLVED OR REJECTED");
});
});
{
"name": "final-fairies-shut-7u1y1",
"productName": "final-fairies-shut-7u1y1",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "alex",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "29.0.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment