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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 79 additions and 20 deletions

View file

@ -153,7 +153,7 @@
"@langchain/textsplitters": "0.0.3", "@langchain/textsplitters": "0.0.3",
"@mozilla/readability": "^0.5.0", "@mozilla/readability": "^0.5.0",
"@n8n/typeorm": "0.3.20-10", "@n8n/typeorm": "0.3.20-10",
"@n8n/vm2": "3.9.24", "@n8n/vm2": "3.9.25",
"@pinecone-database/pinecone": "3.0.0", "@pinecone-database/pinecone": "3.0.0",
"@qdrant/js-client-rest": "1.9.0", "@qdrant/js-client-rest": "1.9.0",
"@supabase/supabase-js": "2.43.4", "@supabase/supabase-js": "2.43.4",

View file

@ -59,6 +59,34 @@
"type": "n8n-nodes-base.code", "type": "n8n-nodes-base.code",
"typeVersion": 1, "typeVersion": 1,
"position": [460, 860] "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": { "pinData": {
@ -103,6 +131,34 @@
"myNewField": 2 "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": { "connections": {
@ -139,6 +195,16 @@
"node": "Run Once for Each Item (Legacy Syntax)", "node": "Run Once for Each Item (Legacy Syntax)",
"type": "main", "type": "main",
"index": 0 "index": 0
},
{
"node": "With Async Functions",
"type": "main",
"index": 0
},
{
"node": "With Promises",
"type": "main",
"index": 0
} }
] ]
] ]

View file

@ -830,7 +830,7 @@
"dependencies": { "dependencies": {
"@kafkajs/confluent-schema-registry": "1.0.6", "@kafkajs/confluent-schema-registry": "1.0.6",
"@n8n/imap": "workspace:*", "@n8n/imap": "workspace:*",
"@n8n/vm2": "3.9.24", "@n8n/vm2": "3.9.25",
"amqplib": "0.10.3", "amqplib": "0.10.3",
"alasql": "^4.4.0", "alasql": "^4.4.0",
"aws4": "1.11.0", "aws4": "1.11.0",

View file

@ -390,8 +390,8 @@ importers:
specifier: 0.3.20-10 specifier: 0.3.20-10
version: 0.3.20-10(@sentry/node@7.87.0)(ioredis@5.3.2)(mssql@10.0.2)(mysql2@3.10.0)(pg@8.11.3)(redis@4.6.12)(sqlite3@5.1.7) version: 0.3.20-10(@sentry/node@7.87.0)(ioredis@5.3.2)(mssql@10.0.2)(mysql2@3.10.0)(pg@8.11.3)(redis@4.6.12)(sqlite3@5.1.7)
'@n8n/vm2': '@n8n/vm2':
specifier: 3.9.24 specifier: 3.9.25
version: 3.9.24 version: 3.9.25
'@pinecone-database/pinecone': '@pinecone-database/pinecone':
specifier: 3.0.0 specifier: 3.0.0
version: 3.0.0 version: 3.0.0
@ -1448,8 +1448,8 @@ importers:
specifier: workspace:* specifier: workspace:*
version: link:../@n8n/imap version: link:../@n8n/imap
'@n8n/vm2': '@n8n/vm2':
specifier: 3.9.24 specifier: 3.9.25
version: 3.9.24 version: 3.9.25
alasql: alasql:
specifier: ^4.4.0 specifier: ^4.4.0
version: 4.4.0(encoding@0.1.13) version: 4.4.0(encoding@0.1.13)
@ -4211,8 +4211,8 @@ packages:
typeorm-aurora-data-api-driver: typeorm-aurora-data-api-driver:
optional: true optional: true
'@n8n/vm2@3.9.24': '@n8n/vm2@3.9.25':
resolution: {integrity: sha512-O4z67yVgUs2FHkcw3vbGnxdC1EglpzOj966kPkK4gtW+ZmTTFRfEB+2Ehq6PMthgg/Ou5JCLSR3wvQIZFFt4Pg==} resolution: {integrity: sha512-qoGLFzyHBW7HKpwXkl05QKsIh3GkDw6lOiTOWYlUDnOIQ1b7EgM+O5EMjrMGy7r+kz52+Q7o6GLxBIcxVI8rEg==}
engines: {node: '>=18.10', pnpm: '>=9.6'} engines: {node: '>=18.10', pnpm: '>=9.6'}
hasBin: true hasBin: true
@ -6008,11 +6008,6 @@ packages:
engines: {node: '>=0.4.0'} engines: {node: '>=0.4.0'}
hasBin: true hasBin: true
acorn@8.11.2:
resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==}
engines: {node: '>=0.4.0'}
hasBin: true
acorn@8.12.1: acorn@8.12.1:
resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==} resolution: {integrity: sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==}
engines: {node: '>=0.4.0'} engines: {node: '>=0.4.0'}
@ -16710,7 +16705,7 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
'@n8n/vm2@3.9.24': '@n8n/vm2@3.9.25':
dependencies: dependencies:
acorn: 8.12.1 acorn: 8.12.1
acorn-walk: 8.3.2 acorn-walk: 8.3.2
@ -19360,16 +19355,14 @@ snapshots:
acorn: 8.12.1 acorn: 8.12.1
acorn-walk: 8.3.2 acorn-walk: 8.3.2
acorn-jsx@5.3.2(acorn@8.11.2): acorn-jsx@5.3.2(acorn@8.12.1):
dependencies: dependencies:
acorn: 8.11.2 acorn: 8.12.1
acorn-walk@8.3.2: {} acorn-walk@8.3.2: {}
acorn@7.4.1: {} acorn@7.4.1: {}
acorn@8.11.2: {}
acorn@8.12.1: {} acorn@8.12.1: {}
address@1.2.2: {} address@1.2.2: {}
@ -21481,8 +21474,8 @@ snapshots:
espree@9.6.1: espree@9.6.1:
dependencies: dependencies:
acorn: 8.11.2 acorn: 8.12.1
acorn-jsx: 5.3.2(acorn@8.11.2) acorn-jsx: 5.3.2(acorn@8.12.1)
eslint-visitor-keys: 3.4.3 eslint-visitor-keys: 3.4.3
esprima-next@5.8.4: {} esprima-next@5.8.4: {}