notify(event, internal, data) { logger.debug('notify() [event:%s]', event); if (this._closed) { logger.warn('notify() | Channel closed'); return; } const notification = { event, internal, data }; const ns = netstring.nsWrite(JSON.stringify(notification)); if (Buffer.byteLength(ns) > NS_MESSAGE_MAX_LEN) { logger.error('notify() | notification too big [length:%s]', Buffer.byteLength(ns)); return; } // This may throw if closed or remote side ended. // Terminate with \r\n since we are expecting for it on the python side. try { this._sendSocket.write(ns); } catch (error) { logger.warn('notify() | failed: %s', String(error)); } }
const sent = this._sents.get(msg.id); if (!sent) { logger.error('received response does not match any sent request [id:%s]', msg.id); return; sent.resolve(msg.data); else if (msg.error) { logger.warn('request failed [method:%s, id:%s]: %s', sent.method, sent.id, msg.reason); switch (msg.error) { case 'TypeError': sent.reject(new TypeError(msg.reason)); logger.error('received response is not accepted nor rejected [method:%s, id:%s]', sent.method, sent.id); logger.error('received message is not a response nor a notification');
logger.error(`handler creation in the worker failed: ${error}`); this.close(); });
logger.error('ignoring unknown event "%s"', event);
logger.error('receiving buffer is full, discarding all data into it'); logger.error('invalid netstring data received from the worker process: %s', String(error)); this._sendSocket.on('error', (error) => (logger.error('send Channel error: %s', String(error)))); this._recvSocket.on('end', () => (logger.debug('receive Channel ended by the worker process'))); this._recvSocket.on('error', (error) => (logger.error('receive Channel error: %s', String(error))));
logger.error('ignoring unknown event "%s"', event);
spawnDone = true; if (code === 42) { logger.error('worker process failed due to wrong settings [pid:%s]', this._pid); this.emit('@failure', new TypeError('wrong settings')); logger.error('worker process failed unexpectedly [pid:%s, code:%s, signal:%s]', this._pid, code, signal); this.emit('@failure', new Error(`[pid:${this._pid}, code:${code}, signal:${signal}]`)); logger.error('worker process died unexpectedly [pid:%s, code:%s, signal:%s]', this._pid, code, signal); this.safeEmit('died', new Error(`[pid:${this._pid}, code:${code}, signal:${signal}]`)); if (!spawnDone) { spawnDone = true; logger.error('worker process failed [pid:%s]: %s', this._pid, error.message); this.emit('@failure', error); logger.error('worker process error [pid:%s]: %s', this._pid, error.message); this.safeEmit('died', error); for (const line of buffer.toString('utf8').split('\n')) { if (line) logger.error(`(stderr) ${line}`);
logger.error( 'worker process failed due to wrong settings [pid:%s]', this._pid); logger.error( 'worker process failed unexpectedly [pid:%s, code:%s, signal:%s]', this._pid, code, signal); logger.error( 'worker process died unexpectedly [pid:%s, code:%s, signal:%s]', this._pid, code, signal); logger.error( 'worker process failed [pid:%s]: %s', this._pid, error.message); logger.error( 'worker process error [pid:%s]: %s', this._pid, error.message); logger.error(`(stderr) ${line}`);
logger.error( 'notify() | notification too big [length:%s]', Buffer.byteLength(ns));
logger.error( 'received response does not match any sent request [id:%s]', msg.id); else if (msg.error) sent.method, sent.id, msg.reason); switch (msg.error) logger.error( 'received response is not accepted nor rejected [method:%s, id:%s]', sent.method, sent.id); logger.error( 'received message is not a response nor a notification');
logger.error('ignoring unknown event "%s"', event);
.catch((error) => logger.error(`handler creation in the worker failed: ${error}`);
logger.error('ignoring unknown event "%s"', event);