Skip to content

Commit 6d2b64e

Browse files
authored
fix: fix compatibility with Electron apps (#823)
* Update cache.js The recent change made in v4.1.5 breaks compatibility with Electron based applications. This is because the renderer process within Electron uses a similar library as the one within Node JS, but has small differences to the actual library being used. You can read more about it (and the suggested fix) over at [electron/electron#21162](electron/electron#21162). This change uses the suggested line in the linked issue to specify that `setTimeout` should use the functionality built into Node instead of the Electron based one. I've already tested this fix in my project and it seems to work fine with this change. * Add setTimeout variable for Electron compatibility to info.js * Fix linter issue
1 parent 5f6b703 commit 6d2b64e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/cache.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { setTimeout } = require('timers');
2+
13
// A cache that expires.
24
module.exports = class Cache extends Map {
35
constructor(timeout = 1000) {

lib/info.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const querystring = require('querystring');
33
const sax = require('sax');
44
const miniget = require('miniget');
55
const utils = require('./utils');
6+
// Forces Node JS version of setTimeout for Electron based applications
7+
const { setTimeout } = require('timers');
68
const formatUtils = require('./format-utils');
79
const urlUtils = require('./url-utils');
810
const extras = require('./info-extras');

0 commit comments

Comments
 (0)