mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #48 from servisbot/MVP-9730
undefined fix, plus extra cater for error now
This commit is contained in:
commit
0c262fba56
@ -14,6 +14,10 @@ To make a change to the node-red runtime being used by K4 avalanche:
|
|||||||
When doing dev work dont try to link into k4/k5 it just causes issue, instead just go into the node-modules of k4/k5 and make your changes in there
|
When doing dev work dont try to link into k4/k5 it just causes issue, instead just go into the node-modules of k4/k5 and make your changes in there
|
||||||
|
|
||||||
# CHANGE-LOG
|
# CHANGE-LOG
|
||||||
|
## 0.18.7-patch-13
|
||||||
|
2023-11-13
|
||||||
|
- Small fix for codefile logic
|
||||||
|
|
||||||
## 0.18.7-patch-12
|
## 0.18.7-patch-12
|
||||||
2023-11-09
|
2023-11-09
|
||||||
- Added code file as an alternative to vm for function nodes
|
- Added code file as an alternative to vm for function nodes
|
||||||
|
@ -252,28 +252,26 @@ module.exports = function (RED) {
|
|||||||
} = RED;
|
} = RED;
|
||||||
|
|
||||||
if (codefile) {
|
if (codefile) {
|
||||||
|
workerId = workerId.split(":::")[0];
|
||||||
|
const nodeId = this.id.split(`${organization}-${workerId}-`)[1];
|
||||||
try {
|
try {
|
||||||
const messageToSend = clone(msg);
|
const messageToSend = clone(msg);
|
||||||
delete messageToSend.logger;
|
delete messageToSend.logger;
|
||||||
|
|
||||||
const beforeCodefile = process.hrtime();
|
const beforeCodefile = process.hrtime();
|
||||||
const {
|
const {
|
||||||
result: {
|
payload: {
|
||||||
Result: { msg: responseMessage },
|
result,
|
||||||
|
error
|
||||||
},
|
},
|
||||||
} = await codefile.run({ srcCode: this.func, context: { msg } });
|
requestId
|
||||||
|
} = await codefile.run({ srcCode: this.func, context: { msg } });
|
||||||
|
|
||||||
const afterCodefile = process.hrtime(beforeCodefile);
|
const afterCodefile = process.hrtime(beforeCodefile);
|
||||||
|
|
||||||
responseMessage.logger = logger;
|
|
||||||
payloadValidator.verify(responseMessage);
|
|
||||||
// to make function node return result from code file uncomment this line, and comment out the sendResults above
|
|
||||||
// sendResults(this,msg._msgid, responseMessage);
|
|
||||||
|
|
||||||
workerId = workerId.split(":::")[0];
|
|
||||||
const nodeId = this.id.split(`${organization}-${workerId}-`)[1];
|
|
||||||
lambdaRequestId = responseMessage.lambdaRequestId;
|
|
||||||
const metrics = {
|
const metrics = {
|
||||||
lambdaRequestId: requestId,
|
lambdaRequestId: requestId,
|
||||||
|
action:'codefile-success',
|
||||||
organization,
|
organization,
|
||||||
workerId: workerId,
|
workerId: workerId,
|
||||||
nodeId: nodeId,
|
nodeId: nodeId,
|
||||||
@ -287,12 +285,24 @@ module.exports = function (RED) {
|
|||||||
) / 100
|
) / 100
|
||||||
}ms`,
|
}ms`,
|
||||||
};
|
};
|
||||||
|
if(result){
|
||||||
|
// not required right now since we dont go via this path
|
||||||
|
// const responseMessage = result.msg
|
||||||
|
// responseMessage.logger = logger;
|
||||||
|
// payloadValidator.verify(responseMessage);
|
||||||
|
// sendResults(this,msg._msgid, responseMessage);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
metrics.error = error;
|
||||||
|
metrics.action = 'codefile-error';
|
||||||
|
}
|
||||||
logger.info(JSON.stringify(metrics, null, 2));
|
logger.info(JSON.stringify(metrics, null, 2));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
logger.error(e)
|
||||||
logger.error({
|
logger.error({
|
||||||
message: "Error running codefile",
|
message: "Error running codefile",
|
||||||
error: e,
|
action:'codefile-error',
|
||||||
lambdaRequestId,
|
error: e.message,
|
||||||
organization,
|
organization,
|
||||||
workerId: workerId,
|
workerId: workerId,
|
||||||
nodeId: nodeId,
|
nodeId: nodeId,
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@servisbot/node-red",
|
"name": "@servisbot/node-red",
|
||||||
"version": "0.18.7-patch-11",
|
"version": "0.18.7-patch-12",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user