fix: unix reading (#1953)

Another casualty of the async function refactor. This did fail the arudino tests.
This commit is contained in:
Francis Gulotta 2019-10-02 23:10:57 -04:00 • committed by GitHub
parent bfb47c71da
commit c7ca08f03a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View file

@ -347,7 +347,7 @@ function testBinding(bindingName, Binding, testPort) {
noZalgo = true
})
it('throws when not given a buffer', async () => {
it('rejects when not given a buffer', async () => {
const binding = new Binding({
disconnect,
})

View file

@ -18,13 +18,13 @@ module.exports = async function unixRead(buffer, offset, length) {
}
try {
const bytesRead = await readAsync(this.fd, buffer, offset, length, null)
const { bytesRead } = await readAsync(this.fd, buffer, offset, length, null)
if (bytesRead === 0) {
return this.read(buffer, offset, length)
}
logger('Finished read', bytesRead, 'bytes')
return bytesRead
return { bytesRead, buffer }
} catch (err) {
if (err.code === 'EAGAIN' || err.code === 'EWOULDBLOCK' || err.code === 'EINTR') {
if (!this.isOpen) {