Skip to content

Commit

Permalink
Assure there are no timeout errors after got() has resolved (#528)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstewmon authored and szmarczak committed Jul 18, 2018
1 parent 46d1217 commit 13bb0fa
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/timeout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import getStream from 'get-stream';
import test from 'ava';
import pEvent from 'p-event';
import delay from 'delay';
Expand Down Expand Up @@ -142,3 +143,18 @@ test('timeout with streams', async t => {
});
await t.throws(pEvent(stream, 'response'), {code: 'ETIMEDOUT'});
});

test('no error emitted when timeout is not breached', async t => {
const stream = got.stream(s.url, {
retry: 0,
timeout: {
request: reqDelay * 2
}
});
stream.on('error', err => {
t.fail(`error was emitted: ${err}`);
});
await getStream(stream);
await delay(reqDelay * 3);
t.pass();
});

0 comments on commit 13bb0fa

Please sign in to comment.