From 0c2895701626b5d55dc645e475378bf8a6882e19 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Tue, 4 May 2021 13:09:32 +0100 Subject: [PATCH] lang: funcs: Funcs that never load are fatal If there is a programming error in any func Stream() implementation then the node could never output anything, causing the engine to hang indefinitely waiting for an initial value that will never come, Nodes keep track of whether they are loaded, so testing for this occurence is pretty simple. Any nodes that do not return output at least once before they close their output channel can be considered a fatal error on which the engine will exit. Signed-off-by: Joe Groocock --- lang/funcs/engine.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lang/funcs/engine.go b/lang/funcs/engine.go index 9ab4ad81..e5a06d76 100644 --- a/lang/funcs/engine.go +++ b/lang/funcs/engine.go @@ -498,6 +498,15 @@ func (obj *Engine) Run() error { } // no more output values are coming... obj.Logf("func `%s` stopped", node) + + // nodes that never loaded will cause the engine to hang + if !node.loaded { + select { + case obj.ag <- fmt.Errorf("func `%s` stopped before it was loaded", node): + case <-obj.closeChan: + return + } + } }(vertex) }