Do not garbage collect sessions
This commit is contained in:
parent
01ebc77228
commit
d23d9dcf01
1 changed files with 7 additions and 1 deletions
|
@ -2,7 +2,7 @@ const {EventEmitter} = require('events')
|
||||||
const {app} = require('electron')
|
const {app} = require('electron')
|
||||||
const {fromPartition, _setWrapSession} = process.atomBinding('session')
|
const {fromPartition, _setWrapSession} = process.atomBinding('session')
|
||||||
|
|
||||||
// Returns the default session.
|
// Public API.
|
||||||
Object.defineProperties(exports, {
|
Object.defineProperties(exports, {
|
||||||
defaultSession: {
|
defaultSession: {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
|
@ -14,9 +14,15 @@ Object.defineProperties(exports, {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const sessions = []
|
||||||
|
|
||||||
// Wraps native Session class.
|
// Wraps native Session class.
|
||||||
_setWrapSession(function (session) {
|
_setWrapSession(function (session) {
|
||||||
// Session is an EventEmitter.
|
// Session is an EventEmitter.
|
||||||
Object.setPrototypeOf(session, EventEmitter.prototype)
|
Object.setPrototypeOf(session, EventEmitter.prototype)
|
||||||
app.emit('session-created', session)
|
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)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue