node-unix-dgram icon indicating copy to clipboard operation
node-unix-dgram copied to clipboard

Improve mismatched type handling.

Open opnet opened this issue 8 years ago • 1 comments

When something other than an instance of Buffer is sent to the send* methods an assertion fails causing node to coredump. It seems more reasonable to throw TypeError instead.

> const dgram = require('unix-dgram')
undefined
> const socket = dgram.createSocket('unix_dgram')
undefined
> socket.connect('/run/wpa_supplicant/wlan0')
undefined
> socket.send('ATTACH')
/usr/lib/electron/1.2.8/electron -i: ../src/unix_dgram.cc:304: Nan::NAN_METHOD_RETURN_TYPE {anonymous}::Send(Nan::NAN_METHOD_ARGS_TYPE): Assertion `node::Buffer::HasInstance(buf)' failed.
Aborted (core dumped)\

I can create a pull request for this as well if you guys want.

opnet avatar Feb 13 '17 15:02 opnet

A pull request would be welcome.

bnoordhuis avatar Feb 13 '17 15:02 bnoordhuis