Skip to content

Commit 78ecaed

Browse files
authored
fix: send-put node not continuing if first result is pending (#44)
1 parent c2c5c3d commit 78ecaed

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

signalk-send-put.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function(RED) {
1111
console.error(err.stack)
1212
node.status({fill:"red",shape:"dot",text:err.message})
1313
}
14-
14+
1515
node.on('input', msg => {
1616
node.status({fill:"yellow",shape:"dot",text:`sending...`})
1717
try {
@@ -20,31 +20,16 @@ module.exports = function(RED) {
2020
if ( reply.state === 'COMPLETED' ) {
2121
if ( reply.statusCode === 200 ) {
2222
node.status({fill:'green',shape:"dot",text:`value: ${msg.payload}`})
23+
node.send([{ payload: reply}, null])
24+
} else if ( reply.state === 'PENDING' ) {
25+
node.status({fill:'yellow',shape:"dot",text:'pending...'})
2326
} else {
2427
node.status({fill:'red',shape:"dot",text:`error`})
2528
node.error(`put error ${reply.statusCode} ${reply.message || ''}`)
29+
node.send([null, { payload: reply}])
2630
}
2731
}
2832
}, config.source && config.source.length > 0 ? config.source : undefined)
29-
Promise.resolve(res)
30-
.then(reply => {
31-
let fill
32-
let text
33-
if ( !app.queryRequest || (reply.state === 'COMPLETED' && reply.statusCode === 200) ) {
34-
fill = 'green'
35-
text = `value: ${msg.payload}`
36-
node.send([msg, null])
37-
} else if ( reply.state === 'PENDING' ) {
38-
fill = 'yellow'
39-
text = 'pending...'
40-
} else {
41-
fill = 'red'
42-
text = `error : ${reply.statusCode} ${reply.message || ''}`
43-
node.send([null, msg])
44-
}
45-
node.status({fill:fill,shape:"dot",text:text})
46-
})
47-
.catch(onError)
4833
} catch (err) {
4934
onError(err)
5035
}

0 commit comments

Comments
 (0)