making the net module usable only after the ready event.
This commit is contained in:
parent
ac9e6eda95
commit
0e13b8dd01
1 changed files with 5 additions and 0 deletions
|
@ -7,6 +7,7 @@ const Readable = require('stream').Readable
|
|||
const binding = process.atomBinding('net')
|
||||
const {net, Net} = binding
|
||||
const {URLRequest} = net
|
||||
const {app} = require('electron')
|
||||
|
||||
Object.setPrototypeOf(Net.prototype, EventEmitter.prototype)
|
||||
Object.setPrototypeOf(URLRequest.prototype, EventEmitter.prototype)
|
||||
|
@ -106,6 +107,10 @@ class ClientRequest extends EventEmitter {
|
|||
constructor (options, callback) {
|
||||
super()
|
||||
|
||||
if (!app.isReady()) {
|
||||
throw new Error('net module can only be used after app is ready')
|
||||
}
|
||||
|
||||
if (typeof options === 'string') {
|
||||
options = url.parse(options)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue