Skip to content

Commit

Permalink
Fix issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners committed Aug 10, 2016
1 parent ce576fd commit 8dea3d1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
2 changes: 2 additions & 0 deletions psock.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,5 @@ const myTransport = through2.obj(function transport (chunk, enc, cb) {
})

pump(process.stdin, split2(), myTransport)

process.stdin.on('close', () => { shutdown() })
5 changes: 5 additions & 0 deletions test/fixtures/issue5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict'

const pino = require('pino')()
pino.info('hello world')
setTimeout(() => { throw new Error('uncaught') }, 20)
27 changes: 27 additions & 0 deletions test/issue5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict'
/* eslint-env node, mocha */

const net = require('net')
const path = require('path')
const spawn = require('child_process').spawn
const expect = require('chai').expect

test('issue #5', function (done) {
const server = net.createServer()
server.listen(() => {
const scriptPath = path.join(__dirname, 'fixtures', 'issue5.js')
const script = spawn('node', [ scriptPath ])
const psockPath = path.join(__dirname, '..', 'psock.js')
const psock = spawn('node', [ psockPath, '-a', server.address().address, '-p', server.address().port, '-m', 'tcp', '-ne' ])

let output = ''
script.stdout.pipe(psock.stdin)
psock.stdin.on('data', (data) => { output += data.toString() })
psock.stdout.on('close', () => {
server.close(() => {
expect(output.length > 0)
done()
})
})
})
})

0 comments on commit 8dea3d1

Please sign in to comment.