fix(core): VM2 sandbox should not throw on new Promise (#10298)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-08-06 15:16:33 +02:00
committed by GitHub
parent f6fc287cc7
commit 7e95f9e2e4
4 changed files with 79 additions and 20 deletions

View File

@@ -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": {
@@ -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": {
@@ -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
}
]
]