n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
48.77k stars 7.72k forks source link

Batch Size / Interval not working if BatchSize items >2 (HTTP Request Node) #1308

Closed maxmarines closed 3 years ago

maxmarines commented 3 years ago

Describe the bug Batch Size / Interval not working if BatchSize items >2 in HTTP Request node.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'HTTP Request'
  2. Set 'Batch Interval:2000'
  3. Set 'Batch Size:5'
  4. See error - delay ( Batch Interval) only between the first and second request. (2,3,4,5 requests are sent simultaneously ) screen

Expected behavior Batch Interval between all 5 requests.

Environment (please complete the following information):

Additional info: my WorkFlow code

{ "name": "Parse", "nodes": [ { "parameters": {}, "name": "Start", "type": "n8n-nodes-base.start", "typeVersion": 1, "position": [ 280, 80 ] }, { "parameters": { "url": "https://news.ycombinator.com/", "responseFormat": "string", "options": {} }, "name": "HTTP Request", "type": "n8n-nodes-base.httpRequest", "position": [ 460, 100 ], "typeVersion": 1 }, { "parameters": { "extractionValues": { "values": [ { "key": "item", "cssSelector": "tr.athing", "returnValue": "html", "returnArray": true } ] }, "options": {} }, "name": "HTML Extract Items", "type": "n8n-nodes-base.htmlExtract", "position": [ 660, 100 ], "typeVersion": 1 }, { "parameters": { "dataPropertyName": "item", "extractionValues": { "values": [ { "key": "title", "cssSelector": "a" }, { "key": "url", "cssSelector": "a.storylink", "returnValue": "attribute", "attribute": "href" }, { "key": "rank", "cssSelector": ".rank" } ] }, "options": {} }, "name": "HTML Extract Data", "type": "n8n-nodes-base.htmlExtract", "position": [ 850, 90 ], "typeVersion": 1 }, { "parameters": { "batchSize": 5, "options": { "reset": false } }, "name": "SplitInBatches1", "type": "n8n-nodes-base.splitInBatches", "typeVersion": 1, "position": [ 1080, 30 ] }, { "parameters": { "url": "https://webhook.site/8e0a006a-099a-48d1-b300-824f3c3ec3ef", "options": { "batchInterval": 2000, "batchSize": 5 } }, "name": "HTTP Request2", "type": "n8n-nodes-base.httpRequest", "typeVersion": 1, "position": [ 1310, 30 ] } ], "connections": { "HTTP Request": { "main": [ [ { "node": "HTML Extract Items", "type": "main", "index": 0 } ] ] }, "HTML Extract Data": { "main": [ [ { "node": "SplitInBatches1", "type": "main", "index": 0 } ] ] }, "HTML Extract Items": { "main": [ [ { "node": "HTML Extract Data", "type": "main", "index": 0 } ] ] }, "SplitInBatches1": { "main": [ [ { "node": "HTTP Request2", "type": "main", "index": 0 } ] ] }, "Start": { "main": [ [] ] } }, "active": false, "settings": {}, "id": "51" }

for test localhost please go to https://webhook.site/ , copy your unique URL and set in URL in HTTP Request2 (last node in workflow).

RicardoE105 commented 3 years ago

@maxmarines Had a quick look and this does not seem to be a bug. Just remove the split batches node and it should work as expected. The split batches node is not needed. the HTPP will iterate automatically over all items. Can you please confirm that it solves the issue? Thanks.

maxmarines commented 3 years ago

@RicardoE105 Thank you, your advice partially worked. When checking, it turned out that this function works only if the BatchSize >=2. Set Batch Size value to -1/0/1 does not allow you to send requests one at a time and all requests are sent together, with no set delay.

New WorkFlow without Split-Batches node

{ "name": "", "nodes": [ { "parameters": {}, "name": "Start", "type": "n8n-nodes-base.start", "typeVersion": 1, "position": [ -310, 500 ] }, { "parameters": { "url": "https://news.ycombinator.com/", "responseFormat": "string", "options": {} }, "name": "HTTP Request", "type": "n8n-nodes-base.httpRequest", "position": [ -170, 520 ], "typeVersion": 1 }, { "parameters": { "extractionValues": { "values": [ { "key": "item", "cssSelector": "tr.athing", "returnValue": "html", "returnArray": true } ] }, "options": {} }, "name": "HTML Extract Items", "type": "n8n-nodes-base.htmlExtract", "position": [ 30, 520 ], "typeVersion": 1 }, { "parameters": { "dataPropertyName": "item", "extractionValues": { "values": [ { "key": "title", "cssSelector": "a" }, { "key": "url", "cssSelector": "a.storylink", "returnValue": "attribute", "attribute": "href" }, { "key": "rank", "cssSelector": ".rank" } ] }, "options": { "trimValues": true } }, "name": "HTML Extract Data", "type": "n8n-nodes-base.htmlExtract", "position": [ 220, 510 ], "typeVersion": 1 }, { "parameters": { "url": "https://webhook.site/8e0a006a-099a-48d1-b300-824f3c3ec3ef", "options": { "batchInterval": 2000, "batchSize": 3 }, "queryParametersUi": { "parameter": [ {} ] } }, "name": "HTTP Request2", "type": "n8n-nodes-base.httpRequest", "typeVersion": 1, "position": [ 680, 450 ] } ], "connections": { "HTTP Request": { "main": [ [ { "node": "HTML Extract Items", "type": "main", "index": 0 } ] ] }, "HTML Extract Data": { "main": [ [ { "node": "HTTP Request2", "type": "main", "index": 0 } ] ] }, "HTML Extract Items": { "main": [ [ { "node": "HTML Extract Data", "type": "main", "index": 0 } ] ] }, "Start": { "main": [ [ { "node": "HTTP Request", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": {} }

janober commented 3 years ago

Got fixed and will be released with the next version.

janober commented 3 years ago

Got released with n8n@0.101.0