rock-req 5.1.1 → 5.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -23
- package/index.js +2 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
<p align="center">
|
|
3
|
-
<img src="https://raw.githubusercontent.com/carboneio/rock-req/master/doc/rock-req-logo.svg" alt="rock-req logo" height="
|
|
3
|
+
<img src="https://raw.githubusercontent.com/carboneio/rock-req/master/doc/rock-req-logo.svg" alt="rock-req logo" height="150"/>
|
|
4
4
|
</p>
|
|
5
5
|
|
|
6
|
-
<h1 align="center" style="border-bottom:none;
|
|
6
|
+
<h1 align="center" style="border-bottom:none;">Rock-req</h1>
|
|
7
7
|
|
|
8
8
|
<p align="center">⭐️⭐️ Ensure your HTTP requests always reach their destination as <b>efficiently</b> as possible! ⭐️⭐️</p>
|
|
9
|
-
<p align="center">Tested on Mac, Linux, Windows with NodeJS 16, 18, 19</p>
|
|
9
|
+
<p align="center">Tested on Mac, Linux, Windows with NodeJS 16, 18, 19, 20</p>
|
|
10
10
|
|
|
11
11
|
[![npm][npm-image]][npm-url] [![ci][ci-image]][ci-url] [![javascript style guide][standard-image]][standard-url]
|
|
12
12
|
|
|
@@ -54,24 +54,26 @@ When the callback is called, the request is 100% finished, even with streams.
|
|
|
54
54
|
Stop using "slow by-default" and "false-light" HTTP request libraries!
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
| Library |
|
|
58
|
-
| ------------
|
|
59
|
-
| rock-req 🙋♂️ | 21797 req/s
|
|
60
|
-
| simple-get | 3260 req/s
|
|
61
|
-
| axios | 4910 req/s
|
|
62
|
-
| got | 1762 req/s
|
|
63
|
-
| fetch | 2102 req/s
|
|
64
|
-
| request | 1869 req/s
|
|
65
|
-
| superagent | 2100 req/s
|
|
66
|
-
| phin | 1164 req/s
|
|
67
|
-
|
|
|
57
|
+
| Library | NodeJS 16 | NodeJS 18 | NodeJS 20* | Size deps inc. |
|
|
58
|
+
| ------------ |--------------:|--------------:| --------------:| --------------:|
|
|
59
|
+
| rock-req 🙋♂️ | 22816 req/s | 21797 req/s | 21964 req/s | 144 LOC |
|
|
60
|
+
| simple-get | 2937 req/s | 3260 req/s | 21258 req/s | 317 LOC |
|
|
61
|
+
| axios | 5090 req/s | 4910 req/s | 3196 req/s | 13983 LOC |
|
|
62
|
+
| got | 2163 req/s | 1762 req/s | 9961 req/s | 9227 LOC |
|
|
63
|
+
| fetch | 2101 req/s | 2102 req/s | 2020 req/s | 13334 LOC |
|
|
64
|
+
| request | 2249 req/s | 1869 req/s | 15815 req/s | 46572 LOC |
|
|
65
|
+
| superagent | 2776 req/s | 2100 req/s | 2895 req/s | 16109 LOC |
|
|
66
|
+
| phin | 3178 req/s | 1164 req/s | 21299 req/s | 331 LOC |
|
|
67
|
+
| _undici_* | 24095 req/s | 24378 req/s | 24191 req/s | 16225 LOC |
|
|
68
68
|
|
|
69
69
|
|
|
70
|
+
> NodeJS 20 activates HTTP keep-alive by default, like `rock-req`
|
|
71
|
+
|
|
70
72
|
> `undici` is a low-level API, faster alternative to the native NodeJS http module. It is the glass ceiling limit for NodeJS.
|
|
71
73
|
|
|
72
74
|
> `rock-req` uses only the native NodeJS http module and provides many high-level features, a lot more than `phin` and `simple-get` with fewer lines of code.
|
|
73
75
|
|
|
74
|
-
> Tested
|
|
76
|
+
> Tested on Macbook Pro M1 Max
|
|
75
77
|
|
|
76
78
|
|
|
77
79
|
## Install
|
|
@@ -593,14 +595,8 @@ Rock-req is a fork of [simple-get](https://github.com/feross/simple-get)
|
|
|
593
595
|
## TODO:
|
|
594
596
|
|
|
595
597
|
- [ ] replace deprecated `url.parse` by `new URL` but new URL is slower than url.parse. Let's see if Node 20 LTS is faster
|
|
596
|
-
- [ ]
|
|
597
|
-
- [ ]
|
|
598
|
-
- [ ] test HTTP abort signal option
|
|
599
|
-
- [ ] test input stream error with 502 error retry. Does stream.resume destroy all streams?
|
|
600
|
-
- [ ] promisify
|
|
601
|
-
- [ ] typescript type
|
|
602
|
-
- [ ] NodesJS 19 doesn't need agent.timeout to exit https://github.com/nodejs/node/issues/47228 https://github.com/nodejs/node/issues/2642
|
|
603
|
-
|
|
598
|
+
- [ ] promisify ?
|
|
599
|
+
- [ ] typescript type ?
|
|
604
600
|
|
|
605
601
|
# Supporters
|
|
606
602
|
|
package/index.js
CHANGED
|
@@ -71,7 +71,7 @@ function extend (defaultOptions = {}) {
|
|
|
71
71
|
streamToCleanOnError.forEach(s => s.destroy(err))
|
|
72
72
|
if (opts.retryOnError.indexOf(err?.code) !== -1 && --opts.remainingRetry > 0) {
|
|
73
73
|
opts.prevError = err
|
|
74
|
-
return setTimeout(rock, opts.retryDelay, opts, cb) // retry
|
|
74
|
+
return setTimeout(rock, opts.retryDelay, opts, cb) // retry
|
|
75
75
|
}
|
|
76
76
|
return cb(err)
|
|
77
77
|
}
|
|
@@ -83,7 +83,7 @@ function extend (defaultOptions = {}) {
|
|
|
83
83
|
}
|
|
84
84
|
function listen (stream, isLast = false) {
|
|
85
85
|
streamToCleanOnError.push(stream)
|
|
86
|
-
stream.
|
|
86
|
+
stream.on('error', onRequestEnd) // do not use once()! A stream can emit mutiple error event
|
|
87
87
|
stream.once('close', () => {
|
|
88
88
|
if (stream.readableEnded === false || stream.writableEnded === false) return onRequestEnd(new Error('ERR_STREAM_PREMATURE_CLOSE'))
|
|
89
89
|
if (isLast === true) return onRequestEnd()
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rock-req",
|
|
3
3
|
"description": "Ultra-light (150 LOC, No dependencies) & Ultra-fast request library with reliable retry on failure, http/https, redirects, gzip/deflate/brotli, extensible, proxy, streams, JSON mode, forms, timeout",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "David Grelaud & Feross Aboukhadijeh"
|
|
7
7
|
},
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"url": "git://github.com/carboneio/rock-req.git"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"test": "tape test/*.js"
|
|
45
|
+
"test": "tape test/*.js",
|
|
46
|
+
"standard": "node_modules/.bin/standard"
|
|
46
47
|
}
|
|
47
48
|
}
|