diff --git a/js/lib/request.js b/js/lib/request.js index 24625827e36..b7cc6420daa 100644 --- a/js/lib/request.js +++ b/js/lib/request.js @@ -9,6 +9,15 @@ const session = electron.session const underscore = require('underscore') const urlParse = require('../../app/common/urlParse') +var cachedDefaultSession = null + +const getDefaultSession = () => { + if (!cachedDefaultSession) { + cachedDefaultSession = session.fromPartition('default') + } + return cachedDefaultSession +} + /** * Sends a network request using Chromium's networks stack instead of Node's. * Depends on there being a loaded browser window available. @@ -17,8 +26,8 @@ const urlParse = require('../../app/common/urlParse') */ module.exports.request = (options, callback) => { var params - var defaultSession = session.defaultSession var responseType = options.responseType || 'text' + var defaultSession = getDefaultSession() if (!defaultSession) return callback(new Error('Request failed, no session available')) @@ -56,7 +65,7 @@ module.exports.request = (options, callback) => { } module.exports.requestDataFile = (url, headers, path, reject, resolve) => { - let defaultSession = session.defaultSession + var defaultSession = getDefaultSession() if (!defaultSession) { reject('Request failed, no session available') } else {