Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/_stream_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,18 @@ StreamWrap.prototype.doWrite = function doWrite(req, bufs) {
// Ensure that this is called once in case of error
pending = 0;

let errCode = 0;
if (err) {
const code = uv[`UV_${err.code}`];
errCode = (err.code && code) ? code : uv.UV_EPIPE;
}

// Ensure that write was dispatched
setImmediate(function() {
// Do not invoke callback twice
if (!self._dequeue(item))
return;

var errCode = 0;
if (err) {
if (err.code && uv['UV_' + err.code])
errCode = uv['UV_' + err.code];
else
errCode = uv.UV_EPIPE;
}

handle.doAfterWrite(req);
handle.finishWrite(req, errCode);
});
Expand Down
6 changes: 3 additions & 3 deletions lib/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const { createPromise,
promiseResolve, promiseReject } = process.binding('util');
const debug = util.debuglog('child_process');

const uv = process.binding('uv');
const Buffer = require('buffer').Buffer;
const Pipe = process.binding('pipe_wrap').Pipe;
const { isUint8Array } = process.binding('util');
const { errname } = process.binding('uv');
const child_process = require('internal/child_process');

const _validateStdio = child_process._validateStdio;
Expand Down Expand Up @@ -267,7 +267,7 @@ exports.execFile = function(file /*, args, options, callback*/) {
if (!ex) {
ex = new Error('Command failed: ' + cmd + '\n' + stderr);
ex.killed = child.killed || killed;
ex.code = code < 0 ? uv.errname(code) : code;
ex.code = code < 0 ? errname(code) : code;
ex.signal = signal;
}

Expand Down Expand Up @@ -565,7 +565,7 @@ function checkExecSyncError(ret, args, cmd) {
err = new Error(msg);
}
if (err) {
err.status = ret.status < 0 ? uv.errname(ret.status) : ret.status;
err.status = ret.status < 0 ? errname(ret.status) : ret.status;
err.signal = ret.signal;
}
return err;
Expand Down
12 changes: 8 additions & 4 deletions lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
const util = require('util');

const cares = process.binding('cares_wrap');
const uv = process.binding('uv');
const internalNet = require('internal/net');
const { customPromisifyArgs } = require('internal/util');
const errors = require('internal/errors');
const {
UV_EAI_MEMORY,
UV_EAI_NODATA,
UV_EAI_NONAME
} = process.binding('uv');

const {
GetAddrInfoReqWrap,
Expand All @@ -43,9 +47,9 @@ const isLegalPort = internalNet.isLegalPort;
function errnoException(err, syscall, hostname) {
// FIXME(bnoordhuis) Remove this backwards compatibility nonsense and pass
// the true error to the user. ENOTFOUND is not even a proper POSIX error!
if (err === uv.UV_EAI_MEMORY ||
err === uv.UV_EAI_NODATA ||
err === uv.UV_EAI_NONAME) {
if (err === UV_EAI_MEMORY ||
err === UV_EAI_NODATA ||
err === UV_EAI_NONAME) {
err = 'ENOTFOUND';
}
var ex = null;
Expand Down
25 changes: 17 additions & 8 deletions lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const assert = require('assert');

const Process = process.binding('process_wrap').Process;
const WriteWrap = process.binding('stream_wrap').WriteWrap;
const uv = process.binding('uv');
const Pipe = process.binding('pipe_wrap').Pipe;
const TTY = process.binding('tty_wrap').TTY;
const TCP = process.binding('tcp_wrap').TCP;
Expand All @@ -20,6 +19,16 @@ const { isUint8Array } = process.binding('util');
const { convertToValidSignal } = require('internal/util');
const spawn_sync = process.binding('spawn_sync');

const {
UV_EAGAIN,
UV_EINVAL,
UV_EMFILE,
UV_ENFILE,
UV_ENOENT,
UV_ENOSYS,
UV_ESRCH
} = process.binding('uv');

const errnoException = util._errnoException;
const SocketListSend = SocketList.SocketListSend;
const SocketListReceive = SocketList.SocketListReceive;
Expand Down