Describe the problem/error/question
Recently changed a large workflow from normal request / response to async request and wait.
I’m requesting research reports from perplexity async and waiting for them to be complete. Don’t care how long it takes, I just want to wait for them to complete or fail. When they are ALL complete continue the workflow. This currently works but continues the workflow by running the rest of it 5 times (5 runs). I want to wait for all the items to be complete and then continue because otherwise it breaks the rest of the workflow.
How can I do that?
This is a mockup of what I’m trying to do.
Please share your workflow
{“nodes”: [{“parameters”: {},“type”: “n8n-nodes-base.wait”,“typeVersion”: 1.1,“position”: [-448,80],“id”: “9588d034-67ae-4b69-8b0f-734d34bd6168”,“name”: “Wait1”,“webhookId”: “ed0eb311-8212-4753-a146-24a90a56bfaf”},{“parameters”: {},“type”: “n8n-nodes-base.manualTrigger”,“typeVersion”: 1,“position”: [-1344,-16],“id”: “0b3d9b22-c3da-4875-8d4e-71353c647c19”,“name”: “When clicking ‘Execute workflow’”},{“parameters”: {“options”: {}},“type”: “n8n-nodes-base.set”,“typeVersion”: 3.4,“position”: [-1120,-16],“id”: “7be657d5-63a3-4e98-a884-981fe8648dd7”,“name”: “Mock data”},{“parameters”: {“jsCode”: “const items = $input.all();\n\n// Get all incomplete items\nconst incompleteItems = items.filter(item => item.json.status !== "COMPLETED");\n\n// If there are any incomplete items, pick one at random\nif (incompleteItems.length > 0) {\n const randomIndex = Math.floor(Math.random() * incompleteItems.length);\n const randomItem = incompleteItems[randomIndex];\n\n // Mark that item as completed\n randomItem.json.status = "COMPLETED";\n}\n\n// Return all items (keeping previous completions)\nreturn items;”},“type”: “n8n-nodes-base.code”,“typeVersion”: 2,“position”: [-896,-16],“id”: “b550105e-e053-439f-a51b-094b48da6a14”,“name”: “API Request (Randomly complete 1 item)”},{“parameters”: {“rules”: {“values”: [{“conditions”: {“options”: {“caseSensitive”: true,“leftValue”: “”,“typeValidation”: “strict”,“version”: 2},“conditions”: [{“leftValue”: “={{ $json.status }}”,“rightValue”: “COMPLETED”,“operator”: {“type”: “string”,“operation”: “equals”},“id”: “87acc565-dd98-40e9-9556-6c7395ac15e7”}],“combinator”: “and”},“renameOutput”: true,“outputKey”: “Completed”},{“conditions”: {“options”: {“caseSensitive”: true,“leftValue”: “”,“typeValidation”: “strict”,“version”: 2},“conditions”: [{“id”: “6e085242-20a4-4154-9130-8f6b31336996”,“leftValue”: “={{ $json.status }}”,“rightValue”: “FAILED”,“operator”: {“type”: “string”,“operation”: “equals”,“name”: “filter.operator.equals”}}],“combinator”: “and”},“renameOutput”: true,“outputKey”: “Failed”},{“conditions”: {“options”: {“caseSensitive”: true,“leftValue”: “”,“typeValidation”: “strict”,“version”: 2},“conditions”: [{“id”: “df557e1c-2275-4ac9-a339-11faaf640c0c”,“leftValue”: “={{ $json.status }}”,“rightValue”: “IN_PROGRESS”,“operator”: {“type”: “string”,“operation”: “equals”,“name”: “filter.operator.equals”}}],“combinator”: “and”},“renameOutput”: true,“outputKey”: “In Progress”}]},“options”: {}},“type”: “n8n-nodes-base.switch”,“typeVersion”: 3.3,“position”: [-672,-112],“id”: “a40aee68-3f3b-4a61-ac02-9b881cc56469”,“name”: “Switch”},{“parameters”: {},“type”: “n8n-nodes-base.noOp”,“typeVersion”: 1,“position”: [-416,-192],“id”: “cd2f7a1c-7f34-4748-a92b-c3f2ccba00ed”,“name”: “No Operation, do nothing”}],“connections”: {“Wait1”: {“main”: [[{“node”: “API Request (Randomly complete 1 item)”,“type”: “main”,“index”: 0}]]},“When clicking ‘Execute workflow’”: {“main”: [[{“node”: “Mock data”,“type”: “main”,“index”: 0}]]},“Mock data”: {“main”: [[{“node”: “API Request (Randomly complete 1 item)”,“type”: “main”,“index”: 0}]]},“API Request (Randomly complete 1 item)”: {“main”: [[{“node”: “Switch”,“type”: “main”,“index”: 0}]]},“Switch”: {“main”: [[{“node”: “No Operation, do nothing”,“type”: “main”,“index”: 0}],,[{“node”: “Wait1”,“type”: “main”,“index”: 0}]]}},“pinData”: {“Mock data”: [{“id”: “450cb082-58bb-41fe-aaec-d217f35cdaf4”,“model”: “sonar-deep-research”,“created_at”: 1761123381,“started_at”: 1761123381,“completed_at”: null,“response”: null,“failed_at”: null,“error_message”: null,“status”: “IN_PROGRESS”},{“id”: “1cde841f-d4e7-4280-8f6f-a3110cc83c68”,“model”: “sonar-deep-research”,“created_at”: 1761123381,“started_at”: 1761123381,“completed_at”: null,“response”: null,“failed_at”: null,“error_message”: null,“status”: “IN_PROGRESS”},{“id”: “e184e3fc-b6f2-4dee-a8de-146200126bfd”,“model”: “sonar-deep-research”,“created_at”: 1761123381,“started_at”: 1761123381,“completed_at”: null,“response”: null,“failed_at”: null,“error_message”: null,“status”: “IN_PROGRESS”},{“id”: “3a395f60-b43e-4b7d-8d9c-1f0857e6cabe”,“model”: “sonar-deep-research”,“created_at”: 1761123381,“started_at”: 1761123381,“completed_at”: null,“response”: null,“failed_at”: null,“error_message”: null,“status”: “IN_PROGRESS”},{“id”: “3738295e-6f28-42c5-b727-3a102f682b4e”,“model”: “sonar-deep-research”,“created_at”: 1761123381,“started_at”: 1761123381,“completed_at”: null,“response”: null,“failed_at”: null,“error_message”: null,“status”: “IN_PROGRESS”}]},“meta”: {“instanceId”: “bc4f08e7f8552bda6e78de5bf5078e390542f531ede98aab2f57ef19f472103e”}}
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: