diff --git a/lib/browser/api/protocol.js b/lib/browser/api/protocol.js index d1c26991d0e3..9d8394f76754 100644 --- a/lib/browser/api/protocol.js +++ b/lib/browser/api/protocol.js @@ -1,4 +1,4 @@ -const {session} = require('electron') +const {app, session} = require('electron') // Global protocol APIs. module.exports = process.atomBinding('protocol') @@ -6,10 +6,18 @@ module.exports = process.atomBinding('protocol') // Fallback protocol APIs of default session. Object.setPrototypeOf(module.exports, new Proxy({}, { get (target, property) { - return (...args) => session.defaultSession.protocol[property](...args) + if (!app.isReady()) return + + const protocol = session.defaultSession.protocol + if (!protocol.hasOwnProperty(property)) return + + // Returning a native function directly would throw error. + return (...args) => protocol[property](...args) }, ownKeys () { + if (!app.isReady()) return [] + return Object.getOwnPropertyNames(session.defaultSession.protocol) },