Code node error

Describe the problem/error/question
The code node gives a timed out error

What is the error message (if any)?

Error: Task request timed out after 60 seconds at LocalTaskRequester.requestExpired (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:304:17) at LocalTaskRequester.onMessage (/usr/local/lib/node_modules/n8n/src/task-runners/task-managers/task-requester.ts:272:10) at TaskBroker.handleRequestTimeout (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:115:50) at Timeout.<anonymous> (/usr/local/lib/node_modules/n8n/src/task-runners/task-broker/task-broker.service.ts:102:9) at listOnTimeout (node:internal/timers:588:17) at processTimers (node:internal/timers:523:7)

Please share your workflow

Share the output returned by the last node

Task request timed out after 60 seconds
Your Code node task was not matched to a runner within the timeout period. This indicates that the task runner is currently down, or not ready, or at capacity, so it cannot service your task.
If you are repeatedly executing Code nodes with long-running tasks across your instance, please space them apart to give the runner time to catch up. If this does not describe your use case, please open a GitHub issue or reach out to support.

Information on your n8n setup

  • n8n version: [email protected]
  • Database (default: SQLite): standard from n8n cloud?
  • n8n EXECUTIONS_PROCESS setting (default: own, main): ?
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system: macOS Sequoia 15.7.3 (24G419)

Could you tell how many count of elements from this array inputData.result.hits? Because the script might need some optimizations to make it faster.

Thanks for your quick response Wilik. Optimization is always good, but it’s only 16 elements in this case.

Okay, if it’s only 16, the Code node should be just running just fine since you mentioned that this is run in a n8n cloud instance. Now I want to know the full workflow or at least the nodes before this Code node to check if there’s a possibility that it might run multiple instances of the Code node resulting in the task runners were not enough to run them in parallel.

You can check it yourself or share it here for the community to help review.

As far as I can see I don’t see any double loops, hereby I sent the part of the flow until the failing code block.

{
“nodes”: [
{
“parameters”: {},
“id”: “33d7fe51-d96d-46a3-a9aa-4339de7f30d6”,
“name”: “When clicking ‘Test workflow’”,
“type”: “n8n-nodes-base.manualTrigger”,
“position”: [
-2144,
720
],
“typeVersion”: 1
},
{
“parameters”: {
“method”: “POST”,
“url”: “=https://login.microsoftonline.com/{{ $vars.microsoft_tenant_id }}/oauth2/token”,
“sendBody”: true,
“contentType”: “form-urlencoded”,
“bodyParameters”: {
“parameters”: [
{
“name”: “grant_type”,
“value”: “client_credentials”
},
{
“name”: “client_id”,
“value”: “={{ $vars.microsoft_client_id }}”
},
{
“name”: “client_secret”,
“value”: “={{ $vars.microsoft_client_secret_value }}”
},
{
“name”: “resource”,
“value”: “https://graph.microsoft.com
}
]
},
“options”: {}
},
“id”: “d9a30da2-55a3-4152-a579-381ebb9f0013”,
“name”: “Auth Microsoft”,
“type”: “n8n-nodes-base.httpRequest”,
“position”: [
-1872,
720
],
“notesInFlow”: true,
“typeVersion”: 4.2,
“notes”: “Get an access token for graph API”
},
{
“parameters”: {
“url”: “https://graph.microsoft.com/v1.0/sites?search=\\\*”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: “Authorization”,
“value”: “=Bearer {{ $json.access_token }}”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-1488,
608
],
“id”: “4c15c65f-d9c9-4f33-a569-c2d10f195441”,
“name”: “Site IDs”,
“disabled”: true
},
{
“parameters”: {
“content”: “## Find Site ID here”,
“height”: 224,
“width”: 224
},
“type”: “n8n-nodes-base.stickyNote”,
“position”: [
-1536,
560
],
“typeVersion”: 1,
“id”: “c283d4d3-6f5c-4f27-8693-0e8c9b21dd24”,
“name”: “Sticky Note”
},
{
“parameters”: {
“content”: “## Download files”,
“height”: 336,
“width”: 960
},
“type”: “n8n-nodes-base.stickyNote”,
“position”: [
-1552,
816
],
“typeVersion”: 1,
“id”: “0590f9ce-d751-4f7e-bf6c-f4cb374bb2c5”,
“name”: “Sticky Note1”
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “26fdc82a-a06b-4e76-8d2f-b9a8cddbeed9”,
“name”: “site-id”,
“value”: “placeholder”,
“type”: “string”
},
{
“id”: “35095b06-1d92-4af6-be79-60bb0b6e1b28”,
“name”: “qdrant-collection”,
“value”: “placeholder”,
“type”: “string”
},
{
“id”: “32da1f9f-377e-4ee1-8a02-22d991408f72”,
“name”: “facet-key”,
“value”: “placeholder”,
“type”: “string”
},
{
“id”: “5c77934e-df7d-4ea8-8a7b-cb3f9944ba87”,
“name”: “max-file-size”,
“value”: {},
“type”: “number”
},
{
“id”: “31d6094a-c880-4705-bdaa-e2ae392aa556”,
“name”: “sharepoint-folder”,
“value”: “placeholderplaceholder”,
“type”: “string”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-1504,
912
],
“id”: “1f44184f-1ded-49e2-b509-8e254b288f2c”,
“name”: “Config”
},
{
“parameters”: {
“resource”: “payload”,
“operation”: “payloadFacets”,
“collectionName”: {
“__rl”: true,
“value”: “={{ $(‘Config’).item.json[‘qdrant-collection’] }}”,
“mode”: “name”
},
“key”: “=metadata.{{ $(‘Config’).item.json[‘facet-key’] }}”,
“limit”: 1000000000000,
“requestOptions”: {}
},
“type”: “n8n-nodes-qdrant.qdrant”,
“typeVersion”: 1,
“position”: [
240,
272
],
“id”: “b9c295c8-c935-48bd-b47f-4f1759ba39d8”,
“name”: “get-playload-facets”,
“credentials”: {
“qdrantRestApi”: {
“id”: “Nht2LISE6NN3FrLC”,
“name”: “Qdrant account”
}
}
},
{
“parameters”: {
“jsCode”: “const inputData = $json; // De input van de Function node\nconst hits = inputData.result.hits; // Toegang tot de hits array\n\n// Haal de zoekterm op.\n// const searchTerm = $(‘set-combi-field’).first().json.id;\nconst searchTerm = $(‘set-combi-field’).first().json[‘combi-sharepoint-last-modified-and-id’];\n\nlet matchFound = false;\nfor (const hit of hits) { \n if (hit.value === searchTerm) { // Gebruik ‘===’ voor exacte match\n // Of hit.value.includes(searchTerm) voor een deelmatch\n matchFound = true;\n break; // Match gevonden, stoppen met zoeken\n }\n}\n\n// Retourneer het resultaat als een nieuw item\nreturn [{ json: { matchFound: matchFound } }];”
},
“type”: “n8n-nodes-base.code”,
“typeVersion”: 2,
“position”: [
464,
272
],
“id”: “efc97274-8e3a-4dd2-9fc8-4ed0d2105321”,
“name”: “Code”
},
{
“parameters”: {
“options”: {}
},
“type”: “n8n-nodes-base.splitInBatches”,
“typeVersion”: 3,
“position”: [
-352,
912
],
“id”: “09b2bb73-80df-405a-973e-71742feb7691”,
“name”: “Loop Over Items”,
“alwaysOutputData”: true
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “40ddbc12-0d2c-4735-839c-764b06595124”,
“name”: “combi-sharepoint-last-modified-and-id”,
“value”: “={{ $json.lastModifiedDateTime }}|{{ $json.id }}”,
“type”: “string”
},
{
“id”: “1b0588fa-e8b4-48e7-be75-63e63da6d693”,
“name”: “”,
“value”: “”,
“type”: “string”
}
]
},
“includeOtherFields”: true,
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
16,
272
],
“id”: “71d80cf2-ba2f-47bf-a306-442cfab32858”,
“name”: “set-combi-field”
},
{
“parameters”: {
“fieldToSplitOut”: “=value”,
“options”: {}
},
“type”: “n8n-nodes-base.splitOut”,
“typeVersion”: 1,
“position”: [
-1056,
912
],
“id”: “fb8dae4c-4482-4689-ac03-5f07906689a4”,
“name”: “Split Out”
},
{
“parameters”: {
“content”: “## Check if file exists in qdrant collection”,
“height”: 336,
“width”: 976
},
“type”: “n8n-nodes-base.stickyNote”,
“position”: [
-496,
208
],
“typeVersion”: 1,
“id”: “a5deaf75-efff-4b38-b853-b726bbf52797”,
“name”: “Sticky Note5”
},
{
“parameters”: {
“conditions”: {
“options”: {
“caseSensitive”: true,
“leftValue”: “”,
“typeValidation”: “strict”,
“version”: 2
},
“conditions”: [
{
“id”: “9118ad2c-80c5-4cb1-a987-510266c13e88”,
“leftValue”: “={{ $json.file.mimeType }}”,
“rightValue”: “application/pdf”,
“operator”: {
“type”: “string”,
“operation”: “equals”
}
},
{
“id”: “fabf98dc-61ed-4987-ae73-3e2c412a8fef”,
“leftValue”: “={{ $json.file.mimeType }}”,
“rightValue”: “application/vnd.openxmlformats-officedocument.wordprocessingml.document”,
“operator”: {
“type”: “string”,
“operation”: “equals”
}
},
{
“id”: “58ab0b20-84a1-4991-bae7-124802ecc3e2”,
“leftValue”: “={{ $json.file.mimeType }}”,
“rightValue”: “application/vnd.openxmlformats-officedocument.presentationml.presentation”,
“operator”: {
“type”: “string”,
“operation”: “equals”,
“name”: “filter.operator.equals”
}
}
],
“combinator”: “or”
},
“options”: {}
},
“type”: “n8n-nodes-base.filter”,
“typeVersion”: 2.2,
“position”: [
-752,
912
],
“id”: “e7f21db6-aa71-41c8-9fc3-34ea02c59f9e”,
“name”: “Filter pdf/docx/pptx”
},
{
“parameters”: {
“url”: “=https://graph.microsoft.com/v1.0/sites/{{ $json[‘site-id’] }}/drive/root:/{{ $json[‘sharepoint-folder’] }}:/children”,
“sendHeaders”: true,
“headerParameters”: {
“parameters”: [
{
“name”: "Authorization ",
“value”: “=Bearer {{ $(‘Auth Microsoft’).item.json.access_token }}”
}
]
},
“options”: {}
},
“type”: “n8n-nodes-base.httpRequest”,
“typeVersion”: 4.2,
“position”: [
-1264,
912
],
“id”: “5ad2e68e-be53-495c-8580-26657dd1943e”,
“name”: “Get files”
}
],
“connections”: {
“When clicking ‘Test workflow’”: {
“main”: [
[
{
“node”: “Auth Microsoft”,
“type”: “main”,
“index”: 0
}
]
]
},
“Auth Microsoft”: {
“main”: [
[
{
“node”: “Config”,
“type”: “main”,
“index”: 0
},
{
“node”: “Site IDs”,
“type”: “main”,
“index”: 0
}
]
]
},
“Site IDs”: {
“main”: [

]
},
“Config”: {
“main”: [
[
{
“node”: “Get files”,
“type”: “main”,
“index”: 0
}
]
]
},
“get-playload-facets”: {
“main”: [
[
{
“node”: “Code”,
“type”: “main”,
“index”: 0
}
]
]
},
“Code”: {
“main”: [
[
{
“node”: “Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Loop Over Items”: {
“main”: [
,
[
{
“node”: “set-combi-field”,
“type”: “main”,
“index”: 0
}
]
]
},
“set-combi-field”: {
“main”: [
[
{
“node”: “get-playload-facets”,
“type”: “main”,
“index”: 0
}
]
]
},
“Split Out”: {
“main”: [
[
{
“node”: “Filter pdf/docx/pptx”,
“type”: “main”,
“index”: 0
}
]
]
},
“Filter pdf/docx/pptx”: {
“main”: [
[
{
“node”: “Loop Over Items”,
“type”: “main”,
“index”: 0
}
]
]
},
“Get files”: {
“main”: [
[
{
“node”: “Split Out”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “6228d5fc9cdee48a75048ec804a7010b4064a6806b811a31b1b849a2408eff6b”
}
}