Does not work in Electron on Windows
See original GitHub issueDespite my best efforts, I cannot get this to work in Electron. The program always fails and shows an error window indicating a C/C++ error, not even a JS error:
My steps:
- Create an empty Node.js project.
- Install
electron
,tdl
, andelectron-rebuild
. - Run
npx electron-rebuild
to retarget the native bindings to Electron. - Download the precompiled Telegram binaries and put them in a
lib
folder. - Create index.js with the following code:
const { Client: TGClient } = require("tdl");
(async () => {
console.log("initialising tg client");
try {
const tgClient = new TGClient({
apiId: 000000,
apiHash: "oops",
binaryPath: "lib/tdjson",
useTestDc: true,
useMutableRename: true,
verbosityLevel: 10
});
console.log("initialised tg client");
await tgClient.connect();
console.log("connected tg client");
tgClient.on("update", (...args) => console.log("tg client: ", ...args));
tgClient.on("error", (...args) => console.error("tg client: ", ...args));
} catch (e) {
console.error(e);
}
})();
- Run
npx electron .
to launch the program. - Program prints “initialised tg client”, indicating that
tdl
successfully loads, but then crashes as soon as I callconnect()
. - Get confronted with this inscrutable error window.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
electron quick start application not working - Stack Overflow
I have to run electron index.html to resolve this issue.
Read more >Any Electron app running on Win 10 16299.19 are not rendered
Electron version: Dont know which electron version is used by apps. I tiried latest Slack, Discord(Including PTB and Canary versions) and ...
Read more >Electron App does not open after following Windows building ...
HELP: Electron App does not open after following Windows building Instructions. directory, i get some weird errors. i have node-gyp installed ...
Read more >Build Instructions (Windows) - Electron
Building Electron is done entirely with command-line scripts and cannot be done with Visual Studio.
Read more >Common Configuration - electron-builder
If you want to use js file, do not name it electron-builder.js . It will conflict with electron-builder package name. Tip. If you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Opened https://github.com/node-ffi-napi/node-ffi-napi/issues/20.
Confirm that it fails on Windows.
It seems that it works with
ffi
instead offfi-napi
. Try this:then replace
require('ffi-napi')
withrequire('ffi')
andrequire('ref-napi')
withrequire('ref')
innode_modules/tdl/dist/tdlib-ffi.js
file.After some debugging I found that it crashes due to async ffi calls. Minimal reproducible example:
(
kernel32
here is just for example, you can use any function. Example fromtdl
: )I think we should open an issue somewhere in nodejs / electron / node-ffi-napi repo.
Versions: