Skip to content

Commit

Permalink
2.9.1 patch: Improve handling of timeout for Node 10
Browse files Browse the repository at this point in the history
  • Loading branch information
ethan7g committed Aug 9, 2018
1 parent 1e896b3 commit 35f5b21
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Jan 05 2018 16:21:31 GMT-0800 (PST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Aug 08 2018 22:35:52 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Jan 05 2018 16:21:31 GMT-0800 (PST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Aug 08 2018 22:35:52 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
9 changes: 5 additions & 4 deletions docs/phin.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ <h1 class="page-title">Source: phin.js</h1>
'method': 'GET',
'headers': {},
'auth': (addr.auth || null),
'timeout': null,
'parse': 'none',
'stream': false
}
Expand All @@ -89,6 +88,8 @@ <h1 class="page-title">Source: phin.js</h1>
}
options.port = Number(options.port)

if (options.hasOwnProperty('timeout')) delete options.timeout

if (options.compressed === true) {
options.headers['accept-encoding'] = 'gzip, deflate'
}
Expand Down Expand Up @@ -156,8 +157,8 @@ <h1 class="page-title">Source: phin.js</h1>
return
}

if (typeof options.timeout === 'number') {
req.setTimeout(options.timeout, () => {
if (typeof opts.timeout === 'number') {
req.setTimeout(opts.timeout, () => {
req.abort()

cb(new Error('Timeout has been reached.'), null)
Expand Down Expand Up @@ -228,7 +229,7 @@ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.htm
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Fri Jan 05 2018 16:21:31 GMT-0800 (PST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Aug 08 2018 22:35:52 GMT-0700 (Pacific Daylight Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion lib/phin.compiled.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions lib/phin.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const phin = (opts, cb) => {
'method': 'GET',
'headers': {},
'auth': (addr.auth || null),
'timeout': null,
'parse': 'none',
'stream': false
}
Expand All @@ -61,6 +60,8 @@ const phin = (opts, cb) => {
}
options.port = Number(options.port)

if (options.hasOwnProperty('timeout')) delete options.timeout

if (options.compressed === true) {
options.headers['accept-encoding'] = 'gzip, deflate'
}
Expand Down Expand Up @@ -128,8 +129,8 @@ const phin = (opts, cb) => {
return
}

if (typeof options.timeout === 'number') {
req.setTimeout(options.timeout, () => {
if (typeof opts.timeout === 'number') {
req.setTimeout(opts.timeout, () => {
req.abort()

cb(new Error('Timeout has been reached.'), null)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phin",
"version": "2.9.0",
"version": "2.9.1",
"description": "Ultra-simple, lightweight, dependency-free Node.JS HTTP request client",
"main": "lib/phin.compiled.js",
"scripts": {
Expand Down

0 comments on commit 35f5b21

Please sign in to comment.