@bauer-group/n8n-nodes-http-throttled-request 0.1.1 → 0.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/LICENSE +21 -21
- package/README.md +272 -272
- package/package.json +64 -64
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) BAUER GROUP
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) BAUER GROUP
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,272 +1,272 @@
|
|
|
1
|
-
# n8n-nodes-http-throttled-request
|
|
2
|
-
|
|
3
|
-
A custom n8n node that extends the HTTP Request functionality with intelligent rate-limit throttling. The node automatically detects rate-limit responses (429 Too Many Requests, etc.) and waits the appropriate time before retrying, using information from response headers.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Automatic Rate Limit Detection**: Detects HTTP 429, 503, and 504 status codes
|
|
8
|
-
- **Smart Wait Time Calculation**: Parses `Retry-After`, `X-RateLimit-*`, and HubSpot-specific headers
|
|
9
|
-
- **Jitter Support**: Prevents thundering herd with configurable random variance
|
|
10
|
-
- **n8n v2 Compatible**: Uses modern `this.helpers.httpRequest()` API
|
|
11
|
-
- **Shadow-Override Ready**: Can replace the core HTTP Request node transparently
|
|
12
|
-
- **Full Authentication Support**: None, Basic Auth, Header Auth, OAuth1, OAuth2
|
|
13
|
-
|
|
14
|
-
## Installation
|
|
15
|
-
|
|
16
|
-
### Prerequisites
|
|
17
|
-
|
|
18
|
-
- Node.js 20+
|
|
19
|
-
- npm 9+
|
|
20
|
-
- n8n instance (self-hosted)
|
|
21
|
-
|
|
22
|
-
### Install from npm
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
npm install n8n-nodes-http-throttled-request
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Install from source
|
|
29
|
-
|
|
30
|
-
1. Clone or download this repository
|
|
31
|
-
2. Build the package:
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
npm install
|
|
35
|
-
npm run build
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
3. Link to your n8n installation:
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
# Navigate to your n8n custom nodes directory
|
|
42
|
-
cd ~/.n8n/nodes
|
|
43
|
-
|
|
44
|
-
# Link the package
|
|
45
|
-
npm link n8n-nodes-http-throttled-request
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
4. Restart your n8n instance
|
|
49
|
-
|
|
50
|
-
### Docker Installation
|
|
51
|
-
|
|
52
|
-
Mount the node package into your n8n container:
|
|
53
|
-
|
|
54
|
-
```yaml
|
|
55
|
-
# docker-compose.yml
|
|
56
|
-
services:
|
|
57
|
-
n8n:
|
|
58
|
-
image: n8nio/n8n
|
|
59
|
-
volumes:
|
|
60
|
-
- ./n8n-nodes-http-throttled-request:/home/node/.n8n/nodes/n8n-nodes-http-throttled-request
|
|
61
|
-
environment:
|
|
62
|
-
- N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/nodes
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Configuration
|
|
66
|
-
|
|
67
|
-
### Node Parameters
|
|
68
|
-
|
|
69
|
-
| Parameter | Type | Default | Description |
|
|
70
|
-
|-----------|------|---------|-------------|
|
|
71
|
-
| **Method** | Options | GET | HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS) |
|
|
72
|
-
| **URL** | String | - | Target URL for the request |
|
|
73
|
-
| **Authentication** | Options | None | Authentication type |
|
|
74
|
-
| **Send Headers** | Boolean | false | Enable custom headers |
|
|
75
|
-
| **Send Body** | Boolean | false | Enable request body |
|
|
76
|
-
| **Throttling aktivieren** | Boolean | true | Enable automatic rate-limit handling |
|
|
77
|
-
|
|
78
|
-
### Throttling Settings
|
|
79
|
-
|
|
80
|
-
When throttling is enabled, additional options become available:
|
|
81
|
-
|
|
82
|
-
| Setting | Type | Default | Description |
|
|
83
|
-
|---------|------|---------|-------------|
|
|
84
|
-
| **HTTP-Codes** | Multi-select | 429 | Status codes that trigger throttling (429, 503, 504) |
|
|
85
|
-
| **Standard-Wartezeit (ms)** | Number | 10000 | Default wait time when no header provides guidance |
|
|
86
|
-
| **Zufaellige Abweichung (+/-%)** | Number | 25 | Jitter percentage to prevent thundering herd |
|
|
87
|
-
| **Max. Throttle-Versuche** | Number | 10 | Maximum retry attempts before failing |
|
|
88
|
-
|
|
89
|
-
### Authentication Types
|
|
90
|
-
|
|
91
|
-
The node supports the following authentication methods:
|
|
92
|
-
|
|
93
|
-
- **None**: No authentication
|
|
94
|
-
- **Basic Auth**: HTTP Basic Authentication (username/password)
|
|
95
|
-
- **Header Auth**: Custom header-based authentication
|
|
96
|
-
- **OAuth1**: OAuth 1.0 authentication
|
|
97
|
-
- **OAuth2**: OAuth 2.0 authentication
|
|
98
|
-
|
|
99
|
-
## Usage Examples
|
|
100
|
-
|
|
101
|
-
### Basic GET Request with Throttling
|
|
102
|
-
|
|
103
|
-
1. Add the "HTTP Request" node to your workflow
|
|
104
|
-
2. Set the URL to your API endpoint
|
|
105
|
-
3. Enable "Throttling aktivieren" (enabled by default)
|
|
106
|
-
4. Configure throttling settings as needed
|
|
107
|
-
5. Execute the workflow
|
|
108
|
-
|
|
109
|
-
### POST Request with JSON Body
|
|
110
|
-
|
|
111
|
-
1. Add the HTTP Request node
|
|
112
|
-
2. Set Method to "POST"
|
|
113
|
-
3. Enter the target URL
|
|
114
|
-
4. Enable "Send Body"
|
|
115
|
-
5. Select "JSON" as Body Content Type
|
|
116
|
-
6. Enter your JSON payload in the Body field
|
|
117
|
-
|
|
118
|
-
### API Request with Rate Limit Handling
|
|
119
|
-
|
|
120
|
-
For APIs that enforce rate limits (e.g., HubSpot, GitHub, Stripe):
|
|
121
|
-
|
|
122
|
-
1. Enable throttling with appropriate HTTP codes (429, 503)
|
|
123
|
-
2. Set a reasonable default wait time (e.g., 10000ms)
|
|
124
|
-
3. Configure max retries based on your workflow timeout
|
|
125
|
-
4. Add jitter (25%) to distribute retry attempts
|
|
126
|
-
|
|
127
|
-
## How It Works
|
|
128
|
-
|
|
129
|
-
### Rate Limit Detection
|
|
130
|
-
|
|
131
|
-
When the node receives a response with a configured throttle status code (429, 503, or 504), it:
|
|
132
|
-
|
|
133
|
-
1. Extracts wait time from response headers
|
|
134
|
-
2. Applies jitter to prevent thundering herd
|
|
135
|
-
3. Waits the calculated time
|
|
136
|
-
4. Retries the request
|
|
137
|
-
5. Repeats until success or max retries reached
|
|
138
|
-
|
|
139
|
-
### Header Priority
|
|
140
|
-
|
|
141
|
-
The node calculates wait time using this priority:
|
|
142
|
-
|
|
143
|
-
1. **Retry-After** (highest priority)
|
|
144
|
-
- Seconds format: `Retry-After: 30`
|
|
145
|
-
- HTTP-Date format: `Retry-After: Wed, 19 Feb 2025 12:00:00 GMT`
|
|
146
|
-
|
|
147
|
-
2. **Rate Limit with Remaining=0**
|
|
148
|
-
- `X-RateLimit-Remaining: 0` combined with reset timestamp
|
|
149
|
-
|
|
150
|
-
3. **Reset Timestamp alone**
|
|
151
|
-
- `X-RateLimit-Reset: 1739966400`
|
|
152
|
-
|
|
153
|
-
4. **Default fallback** (lowest priority)
|
|
154
|
-
- Uses configured default wait time
|
|
155
|
-
|
|
156
|
-
### Supported Headers
|
|
157
|
-
|
|
158
|
-
| Header | Format | Example |
|
|
159
|
-
|--------|--------|---------|
|
|
160
|
-
| `Retry-After` | Seconds or HTTP-Date | `30` or `Wed, 19 Feb 2025 12:00:00 GMT` |
|
|
161
|
-
| `X-RateLimit-Reset` | Unix timestamp | `1739966400` |
|
|
162
|
-
| `X-RateLimit-Remaining` | Integer | `0` |
|
|
163
|
-
| `X-HubSpot-RateLimit-Reset` | Unix timestamp | `1739966400` |
|
|
164
|
-
| `X-HubSpot-RateLimit-Remaining` | Integer | `0` |
|
|
165
|
-
| `RateLimit-Reset` | Unix timestamp | `1739966400` |
|
|
166
|
-
| `RateLimit-Remaining` | Integer | `0` |
|
|
167
|
-
|
|
168
|
-
### Timestamp Detection
|
|
169
|
-
|
|
170
|
-
The node automatically detects timestamp format:
|
|
171
|
-
- Values > 10^12: Treated as milliseconds
|
|
172
|
-
- Values > 10^9: Treated as seconds (Unix timestamp)
|
|
173
|
-
|
|
174
|
-
### Safety Limits
|
|
175
|
-
|
|
176
|
-
- **Maximum wait time**: 5 minutes (300,000ms)
|
|
177
|
-
- **Jitter range**: 0-100%
|
|
178
|
-
- **Minimum jitter result**: 0ms (never negative)
|
|
179
|
-
|
|
180
|
-
## Development
|
|
181
|
-
|
|
182
|
-
### Build
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
npm run build
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Test
|
|
189
|
-
|
|
190
|
-
```bash
|
|
191
|
-
npm test
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### Test with Coverage
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
npm test -- --coverage
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### Project Structure
|
|
201
|
-
|
|
202
|
-
```
|
|
203
|
-
n8n-nodes-http-throttled-request/
|
|
204
|
-
├── package.json # Package configuration
|
|
205
|
-
├── tsconfig.json # TypeScript configuration
|
|
206
|
-
├── README.md # This file
|
|
207
|
-
├── nodes/
|
|
208
|
-
│ └── HttpRequest/
|
|
209
|
-
│ ├── HttpRequestThrottled.node.ts # Main node class
|
|
210
|
-
│ └── throttling.ts # Throttling logic
|
|
211
|
-
└── test/
|
|
212
|
-
└── throttling.test.ts # Unit tests
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## Troubleshooting
|
|
216
|
-
|
|
217
|
-
### Node not appearing in n8n
|
|
218
|
-
|
|
219
|
-
1. Verify the package is installed in the correct location
|
|
220
|
-
2. Check n8n logs for loading errors
|
|
221
|
-
3. Ensure `npm run build` completed successfully
|
|
222
|
-
4. Restart n8n after installation
|
|
223
|
-
|
|
224
|
-
### Throttling not working
|
|
225
|
-
|
|
226
|
-
1. Verify "Throttling aktivieren" is enabled
|
|
227
|
-
2. Check that the API returns one of the configured HTTP codes
|
|
228
|
-
3. Review n8n execution logs for throttling messages
|
|
229
|
-
|
|
230
|
-
### Maximum retries exceeded
|
|
231
|
-
|
|
232
|
-
If you see "Maximale Anzahl Versuche erreicht":
|
|
233
|
-
1. Increase "Max. Throttle-Versuche" setting
|
|
234
|
-
2. Increase "Standard-Wartezeit" to wait longer between retries
|
|
235
|
-
3. Check if the API requires authentication or has other restrictions
|
|
236
|
-
|
|
237
|
-
## API Reference
|
|
238
|
-
|
|
239
|
-
### Throttling Module Exports
|
|
240
|
-
|
|
241
|
-
```typescript
|
|
242
|
-
// Maximum wait time cap (5 minutes)
|
|
243
|
-
export const MAX_THROTTLE_WAIT_MS = 300_000;
|
|
244
|
-
|
|
245
|
-
// Normalize headers to lowercase keys
|
|
246
|
-
export function normalizeHeaders(raw: Record<string, unknown>): Record<string, string>;
|
|
247
|
-
|
|
248
|
-
// Parse Retry-After header to milliseconds
|
|
249
|
-
export function parseRetryAfterToMs(v: string): number | null;
|
|
250
|
-
|
|
251
|
-
// Parse reset timestamp headers to wait milliseconds
|
|
252
|
-
export function parseResetToWaitMs(h: Record<string, string>): number | null;
|
|
253
|
-
|
|
254
|
-
// Compute wait time from response headers
|
|
255
|
-
export function computeWaitMs(rawHeaders: Record<string, unknown>, defaultWaitMs: number): number;
|
|
256
|
-
|
|
257
|
-
// Apply jitter to wait time
|
|
258
|
-
export function applyJitter(baseMs: number, jitterPct: number): number;
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
## License
|
|
262
|
-
|
|
263
|
-
MIT
|
|
264
|
-
|
|
265
|
-
## Contributing
|
|
266
|
-
|
|
267
|
-
1. Fork the repository
|
|
268
|
-
2. Create a feature branch
|
|
269
|
-
3. Make your changes
|
|
270
|
-
4. Run tests: `npm test`
|
|
271
|
-
5. Submit a pull request
|
|
272
|
-
|
|
1
|
+
# n8n-nodes-http-throttled-request
|
|
2
|
+
|
|
3
|
+
A custom n8n node that extends the HTTP Request functionality with intelligent rate-limit throttling. The node automatically detects rate-limit responses (429 Too Many Requests, etc.) and waits the appropriate time before retrying, using information from response headers.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Automatic Rate Limit Detection**: Detects HTTP 429, 503, and 504 status codes
|
|
8
|
+
- **Smart Wait Time Calculation**: Parses `Retry-After`, `X-RateLimit-*`, and HubSpot-specific headers
|
|
9
|
+
- **Jitter Support**: Prevents thundering herd with configurable random variance
|
|
10
|
+
- **n8n v2 Compatible**: Uses modern `this.helpers.httpRequest()` API
|
|
11
|
+
- **Shadow-Override Ready**: Can replace the core HTTP Request node transparently
|
|
12
|
+
- **Full Authentication Support**: None, Basic Auth, Header Auth, OAuth1, OAuth2
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Prerequisites
|
|
17
|
+
|
|
18
|
+
- Node.js 20+
|
|
19
|
+
- npm 9+
|
|
20
|
+
- n8n instance (self-hosted)
|
|
21
|
+
|
|
22
|
+
### Install from npm
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install n8n-nodes-http-throttled-request
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Install from source
|
|
29
|
+
|
|
30
|
+
1. Clone or download this repository
|
|
31
|
+
2. Build the package:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install
|
|
35
|
+
npm run build
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
3. Link to your n8n installation:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Navigate to your n8n custom nodes directory
|
|
42
|
+
cd ~/.n8n/nodes
|
|
43
|
+
|
|
44
|
+
# Link the package
|
|
45
|
+
npm link n8n-nodes-http-throttled-request
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
4. Restart your n8n instance
|
|
49
|
+
|
|
50
|
+
### Docker Installation
|
|
51
|
+
|
|
52
|
+
Mount the node package into your n8n container:
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
# docker-compose.yml
|
|
56
|
+
services:
|
|
57
|
+
n8n:
|
|
58
|
+
image: n8nio/n8n
|
|
59
|
+
volumes:
|
|
60
|
+
- ./n8n-nodes-http-throttled-request:/home/node/.n8n/nodes/n8n-nodes-http-throttled-request
|
|
61
|
+
environment:
|
|
62
|
+
- N8N_CUSTOM_EXTENSIONS=/home/node/.n8n/nodes
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Configuration
|
|
66
|
+
|
|
67
|
+
### Node Parameters
|
|
68
|
+
|
|
69
|
+
| Parameter | Type | Default | Description |
|
|
70
|
+
|-----------|------|---------|-------------|
|
|
71
|
+
| **Method** | Options | GET | HTTP method (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS) |
|
|
72
|
+
| **URL** | String | - | Target URL for the request |
|
|
73
|
+
| **Authentication** | Options | None | Authentication type |
|
|
74
|
+
| **Send Headers** | Boolean | false | Enable custom headers |
|
|
75
|
+
| **Send Body** | Boolean | false | Enable request body |
|
|
76
|
+
| **Throttling aktivieren** | Boolean | true | Enable automatic rate-limit handling |
|
|
77
|
+
|
|
78
|
+
### Throttling Settings
|
|
79
|
+
|
|
80
|
+
When throttling is enabled, additional options become available:
|
|
81
|
+
|
|
82
|
+
| Setting | Type | Default | Description |
|
|
83
|
+
|---------|------|---------|-------------|
|
|
84
|
+
| **HTTP-Codes** | Multi-select | 429 | Status codes that trigger throttling (429, 503, 504) |
|
|
85
|
+
| **Standard-Wartezeit (ms)** | Number | 10000 | Default wait time when no header provides guidance |
|
|
86
|
+
| **Zufaellige Abweichung (+/-%)** | Number | 25 | Jitter percentage to prevent thundering herd |
|
|
87
|
+
| **Max. Throttle-Versuche** | Number | 10 | Maximum retry attempts before failing |
|
|
88
|
+
|
|
89
|
+
### Authentication Types
|
|
90
|
+
|
|
91
|
+
The node supports the following authentication methods:
|
|
92
|
+
|
|
93
|
+
- **None**: No authentication
|
|
94
|
+
- **Basic Auth**: HTTP Basic Authentication (username/password)
|
|
95
|
+
- **Header Auth**: Custom header-based authentication
|
|
96
|
+
- **OAuth1**: OAuth 1.0 authentication
|
|
97
|
+
- **OAuth2**: OAuth 2.0 authentication
|
|
98
|
+
|
|
99
|
+
## Usage Examples
|
|
100
|
+
|
|
101
|
+
### Basic GET Request with Throttling
|
|
102
|
+
|
|
103
|
+
1. Add the "HTTP Request" node to your workflow
|
|
104
|
+
2. Set the URL to your API endpoint
|
|
105
|
+
3. Enable "Throttling aktivieren" (enabled by default)
|
|
106
|
+
4. Configure throttling settings as needed
|
|
107
|
+
5. Execute the workflow
|
|
108
|
+
|
|
109
|
+
### POST Request with JSON Body
|
|
110
|
+
|
|
111
|
+
1. Add the HTTP Request node
|
|
112
|
+
2. Set Method to "POST"
|
|
113
|
+
3. Enter the target URL
|
|
114
|
+
4. Enable "Send Body"
|
|
115
|
+
5. Select "JSON" as Body Content Type
|
|
116
|
+
6. Enter your JSON payload in the Body field
|
|
117
|
+
|
|
118
|
+
### API Request with Rate Limit Handling
|
|
119
|
+
|
|
120
|
+
For APIs that enforce rate limits (e.g., HubSpot, GitHub, Stripe):
|
|
121
|
+
|
|
122
|
+
1. Enable throttling with appropriate HTTP codes (429, 503)
|
|
123
|
+
2. Set a reasonable default wait time (e.g., 10000ms)
|
|
124
|
+
3. Configure max retries based on your workflow timeout
|
|
125
|
+
4. Add jitter (25%) to distribute retry attempts
|
|
126
|
+
|
|
127
|
+
## How It Works
|
|
128
|
+
|
|
129
|
+
### Rate Limit Detection
|
|
130
|
+
|
|
131
|
+
When the node receives a response with a configured throttle status code (429, 503, or 504), it:
|
|
132
|
+
|
|
133
|
+
1. Extracts wait time from response headers
|
|
134
|
+
2. Applies jitter to prevent thundering herd
|
|
135
|
+
3. Waits the calculated time
|
|
136
|
+
4. Retries the request
|
|
137
|
+
5. Repeats until success or max retries reached
|
|
138
|
+
|
|
139
|
+
### Header Priority
|
|
140
|
+
|
|
141
|
+
The node calculates wait time using this priority:
|
|
142
|
+
|
|
143
|
+
1. **Retry-After** (highest priority)
|
|
144
|
+
- Seconds format: `Retry-After: 30`
|
|
145
|
+
- HTTP-Date format: `Retry-After: Wed, 19 Feb 2025 12:00:00 GMT`
|
|
146
|
+
|
|
147
|
+
2. **Rate Limit with Remaining=0**
|
|
148
|
+
- `X-RateLimit-Remaining: 0` combined with reset timestamp
|
|
149
|
+
|
|
150
|
+
3. **Reset Timestamp alone**
|
|
151
|
+
- `X-RateLimit-Reset: 1739966400`
|
|
152
|
+
|
|
153
|
+
4. **Default fallback** (lowest priority)
|
|
154
|
+
- Uses configured default wait time
|
|
155
|
+
|
|
156
|
+
### Supported Headers
|
|
157
|
+
|
|
158
|
+
| Header | Format | Example |
|
|
159
|
+
|--------|--------|---------|
|
|
160
|
+
| `Retry-After` | Seconds or HTTP-Date | `30` or `Wed, 19 Feb 2025 12:00:00 GMT` |
|
|
161
|
+
| `X-RateLimit-Reset` | Unix timestamp | `1739966400` |
|
|
162
|
+
| `X-RateLimit-Remaining` | Integer | `0` |
|
|
163
|
+
| `X-HubSpot-RateLimit-Reset` | Unix timestamp | `1739966400` |
|
|
164
|
+
| `X-HubSpot-RateLimit-Remaining` | Integer | `0` |
|
|
165
|
+
| `RateLimit-Reset` | Unix timestamp | `1739966400` |
|
|
166
|
+
| `RateLimit-Remaining` | Integer | `0` |
|
|
167
|
+
|
|
168
|
+
### Timestamp Detection
|
|
169
|
+
|
|
170
|
+
The node automatically detects timestamp format:
|
|
171
|
+
- Values > 10^12: Treated as milliseconds
|
|
172
|
+
- Values > 10^9: Treated as seconds (Unix timestamp)
|
|
173
|
+
|
|
174
|
+
### Safety Limits
|
|
175
|
+
|
|
176
|
+
- **Maximum wait time**: 5 minutes (300,000ms)
|
|
177
|
+
- **Jitter range**: 0-100%
|
|
178
|
+
- **Minimum jitter result**: 0ms (never negative)
|
|
179
|
+
|
|
180
|
+
## Development
|
|
181
|
+
|
|
182
|
+
### Build
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npm run build
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Test
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm test
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Test with Coverage
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npm test -- --coverage
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Project Structure
|
|
201
|
+
|
|
202
|
+
```
|
|
203
|
+
n8n-nodes-http-throttled-request/
|
|
204
|
+
├── package.json # Package configuration
|
|
205
|
+
├── tsconfig.json # TypeScript configuration
|
|
206
|
+
├── README.md # This file
|
|
207
|
+
├── nodes/
|
|
208
|
+
│ └── HttpRequest/
|
|
209
|
+
│ ├── HttpRequestThrottled.node.ts # Main node class
|
|
210
|
+
│ └── throttling.ts # Throttling logic
|
|
211
|
+
└── test/
|
|
212
|
+
└── throttling.test.ts # Unit tests
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Troubleshooting
|
|
216
|
+
|
|
217
|
+
### Node not appearing in n8n
|
|
218
|
+
|
|
219
|
+
1. Verify the package is installed in the correct location
|
|
220
|
+
2. Check n8n logs for loading errors
|
|
221
|
+
3. Ensure `npm run build` completed successfully
|
|
222
|
+
4. Restart n8n after installation
|
|
223
|
+
|
|
224
|
+
### Throttling not working
|
|
225
|
+
|
|
226
|
+
1. Verify "Throttling aktivieren" is enabled
|
|
227
|
+
2. Check that the API returns one of the configured HTTP codes
|
|
228
|
+
3. Review n8n execution logs for throttling messages
|
|
229
|
+
|
|
230
|
+
### Maximum retries exceeded
|
|
231
|
+
|
|
232
|
+
If you see "Maximale Anzahl Versuche erreicht":
|
|
233
|
+
1. Increase "Max. Throttle-Versuche" setting
|
|
234
|
+
2. Increase "Standard-Wartezeit" to wait longer between retries
|
|
235
|
+
3. Check if the API requires authentication or has other restrictions
|
|
236
|
+
|
|
237
|
+
## API Reference
|
|
238
|
+
|
|
239
|
+
### Throttling Module Exports
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
// Maximum wait time cap (5 minutes)
|
|
243
|
+
export const MAX_THROTTLE_WAIT_MS = 300_000;
|
|
244
|
+
|
|
245
|
+
// Normalize headers to lowercase keys
|
|
246
|
+
export function normalizeHeaders(raw: Record<string, unknown>): Record<string, string>;
|
|
247
|
+
|
|
248
|
+
// Parse Retry-After header to milliseconds
|
|
249
|
+
export function parseRetryAfterToMs(v: string): number | null;
|
|
250
|
+
|
|
251
|
+
// Parse reset timestamp headers to wait milliseconds
|
|
252
|
+
export function parseResetToWaitMs(h: Record<string, string>): number | null;
|
|
253
|
+
|
|
254
|
+
// Compute wait time from response headers
|
|
255
|
+
export function computeWaitMs(rawHeaders: Record<string, unknown>, defaultWaitMs: number): number;
|
|
256
|
+
|
|
257
|
+
// Apply jitter to wait time
|
|
258
|
+
export function applyJitter(baseMs: number, jitterPct: number): number;
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## License
|
|
262
|
+
|
|
263
|
+
MIT
|
|
264
|
+
|
|
265
|
+
## Contributing
|
|
266
|
+
|
|
267
|
+
1. Fork the repository
|
|
268
|
+
2. Create a feature branch
|
|
269
|
+
3. Make your changes
|
|
270
|
+
4. Run tests: `npm test`
|
|
271
|
+
5. Submit a pull request
|
|
272
|
+
|
package/package.json
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bauer-group/n8n-nodes-http-throttled-request",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "n8n community node with built-in HTTP request throttling (rate limiting)",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "https://github.com/bauer-group/EXT-n8n-httpThrottled.git"
|
|
9
|
-
},
|
|
10
|
-
"main": "dist/nodes/HttpRequest/HttpRequestThrottled.node.js",
|
|
11
|
-
"n8n": {
|
|
12
|
-
"nodes": [
|
|
13
|
-
{
|
|
14
|
-
"file": "dist/nodes/HttpRequest/HttpRequestThrottled.node.js"
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist/",
|
|
20
|
-
"package.json",
|
|
21
|
-
"README.md",
|
|
22
|
-
"LICENSE"
|
|
23
|
-
],
|
|
24
|
-
"publishConfig": {
|
|
25
|
-
"access": "public",
|
|
26
|
-
"registry": "https://registry.npmjs.org/"
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"clean": "rimraf dist",
|
|
30
|
-
"build": "tsc -p tsconfig.json",
|
|
31
|
-
"rebuild": "npm run clean && npm run build",
|
|
32
|
-
"test": "jest",
|
|
33
|
-
"prepublishOnly": "npm run build"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {},
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"n8n-workflow": ">=2.9.0 <3",
|
|
38
|
-
"n8n-core": ">=2.9.0 <3"
|
|
39
|
-
},
|
|
40
|
-
"devDependencies": {
|
|
41
|
-
"typescript": "^5.9.3",
|
|
42
|
-
"@types/node": "^25.3.0",
|
|
43
|
-
"jest": "^30.2.0",
|
|
44
|
-
"@types/jest": "^30.0.0",
|
|
45
|
-
"ts-jest": "^29.4.6",
|
|
46
|
-
"n8n-workflow": "^2.9.0",
|
|
47
|
-
"n8n-core": "^2.9.0",
|
|
48
|
-
"rimraf": "^6.1.3"
|
|
49
|
-
},
|
|
50
|
-
"jest": {
|
|
51
|
-
"testEnvironment": "node",
|
|
52
|
-
"testMatch": [
|
|
53
|
-
"**/test/**/*.test.ts"
|
|
54
|
-
],
|
|
55
|
-
"transform": {
|
|
56
|
-
"^.+\\.ts$": [
|
|
57
|
-
"ts-jest",
|
|
58
|
-
{
|
|
59
|
-
"tsconfig": "tsconfig.test.json"
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bauer-group/n8n-nodes-http-throttled-request",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "n8n community node with built-in HTTP request throttling (rate limiting)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/bauer-group/EXT-n8n-httpThrottled.git"
|
|
9
|
+
},
|
|
10
|
+
"main": "dist/nodes/HttpRequest/HttpRequestThrottled.node.js",
|
|
11
|
+
"n8n": {
|
|
12
|
+
"nodes": [
|
|
13
|
+
{
|
|
14
|
+
"file": "dist/nodes/HttpRequest/HttpRequestThrottled.node.js"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/",
|
|
20
|
+
"package.json",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public",
|
|
26
|
+
"registry": "https://registry.npmjs.org/"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"clean": "rimraf dist",
|
|
30
|
+
"build": "tsc -p tsconfig.json",
|
|
31
|
+
"rebuild": "npm run clean && npm run build",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"prepublishOnly": "npm run build"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"n8n-workflow": ">=2.9.0 <3",
|
|
38
|
+
"n8n-core": ">=2.9.0 <3"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"typescript": "^5.9.3",
|
|
42
|
+
"@types/node": "^25.3.0",
|
|
43
|
+
"jest": "^30.2.0",
|
|
44
|
+
"@types/jest": "^30.0.0",
|
|
45
|
+
"ts-jest": "^29.4.6",
|
|
46
|
+
"n8n-workflow": "^2.9.0",
|
|
47
|
+
"n8n-core": "^2.9.0",
|
|
48
|
+
"rimraf": "^6.1.3"
|
|
49
|
+
},
|
|
50
|
+
"jest": {
|
|
51
|
+
"testEnvironment": "node",
|
|
52
|
+
"testMatch": [
|
|
53
|
+
"**/test/**/*.test.ts"
|
|
54
|
+
],
|
|
55
|
+
"transform": {
|
|
56
|
+
"^.+\\.ts$": [
|
|
57
|
+
"ts-jest",
|
|
58
|
+
{
|
|
59
|
+
"tsconfig": "tsconfig.test.json"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|