Skip to content

Commit

Permalink
fix: fix compatibility with Electron apps (#823)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
PrestonN committed Dec 15, 2020
1 parent 5f6b703 commit 6d2b64e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/cache.js
@@ -1,3 +1,5 @@
const { setTimeout } = require('timers');

// A cache that expires.
module.exports = class Cache extends Map {
constructor(timeout = 1000) {
Expand Down
2 changes: 2 additions & 0 deletions lib/info.js
Expand Up @@ -3,6 +3,8 @@ const querystring = require('querystring');
const sax = require('sax');
const miniget = require('miniget');
const utils = require('./utils');
// Forces Node JS version of setTimeout for Electron based applications
const { setTimeout } = require('timers');
const formatUtils = require('./format-utils');
const urlUtils = require('./url-utils');
const extras = require('./info-extras');
Expand Down

0 comments on commit 6d2b64e

Please sign in to comment.