Skip to content

Commit

Permalink
fix(core): VM2 sandbox should not throw on new Promise (#10298)
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Aug 8, 2024
1 parent c5ad03d commit 6677033
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/@n8n/nodes-langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"@langchain/textsplitters": "0.0.3",
"@mozilla/readability": "^0.5.0",
"@n8n/typeorm": "0.3.20-10",
"@n8n/vm2": "3.9.24",
"@n8n/vm2": "3.9.25",
"@pinecone-database/pinecone": "3.0.0",
"@qdrant/js-client-rest": "1.9.0",
"@supabase/supabase-js": "2.43.4",
Expand Down
66 changes: 66 additions & 0 deletions packages/nodes-base/nodes/Code/test/Code.workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,34 @@
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [460, 860]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const json = $input.item.json\njson.myNewField = await (async () => json.value)();\n\nreturn $input.item;"
},
"id": "3cff4a64-c3fd-47d3-a33e-3c446846138f",
"name": "With Async Functions",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [
460,
1200
]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "const json = $input.item.json\njson.myNewField = await new Promise((resolve) => resolve(json.value));\n\nreturn $input.item;"
},
"id": "947e4e3e-2da3-40c5-97da-830c4572fc05",
"name": "With Promises",
"type": "n8n-nodes-base.code",
"typeVersion": 1,
"position": [
460,
1380
]
}
],
"pinData": {
Expand Down Expand Up @@ -103,6 +131,34 @@
"myNewField": 2
}
}
],
"With Async Functions": [
{
"json": {
"value": 1,
"myNewField": 1
}
},
{
"json": {
"value": 2,
"myNewField": 2
}
}
],
"With Promises": [
{
"json": {
"value": 1,
"myNewField": 1
}
},
{
"json": {
"value": 2,
"myNewField": 2
}
}
]
},
"connections": {
Expand Down Expand Up @@ -139,6 +195,16 @@
"node": "Run Once for Each Item (Legacy Syntax)",
"type": "main",
"index": 0
},
{
"node": "With Async Functions",
"type": "main",
"index": 0
},
{
"node": "With Promises",
"type": "main",
"index": 0
}
]
]
Expand Down
2 changes: 1 addition & 1 deletion packages/nodes-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@
"dependencies": {
"@kafkajs/confluent-schema-registry": "1.0.6",
"@n8n/imap": "workspace:*",
"@n8n/vm2": "3.9.24",
"@n8n/vm2": "3.9.25",
"amqplib": "0.10.3",
"alasql": "^4.4.0",
"aws4": "1.11.0",
Expand Down
29 changes: 11 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6677033

Please sign in to comment.