From d23d9dcf014d35b2a00bb59dbde38f1f6ab38525 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 1 Aug 2016 19:35:51 +0900 Subject: [PATCH] Do not garbage collect sessions --- lib/browser/api/session.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/browser/api/session.js b/lib/browser/api/session.js index 86a7902ef597..ab2d27785921 100644 --- a/lib/browser/api/session.js +++ b/lib/browser/api/session.js @@ -2,7 +2,7 @@ const {EventEmitter} = require('events') const {app} = require('electron') const {fromPartition, _setWrapSession} = process.atomBinding('session') -// Returns the default session. +// Public API. Object.defineProperties(exports, { defaultSession: { enumerable: true, @@ -14,9 +14,15 @@ Object.defineProperties(exports, { } }) +const sessions = [] + // Wraps native Session class. _setWrapSession(function (session) { // Session is an EventEmitter. Object.setPrototypeOf(session, EventEmitter.prototype) app.emit('session-created', session) + + // The Sessions should never be garbage collected, since the common pattern is + // to use partition strings, instead of using the Session object directly. + sessions.push(session) })