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 <me@frebib.net>
This commit is contained in:
Joe Groocock
2021-05-04 13:09:32 +01:00
committed by James Shubin
parent 959084040d
commit 0c28957016

View File

@@ -498,6 +498,15 @@ func (obj *Engine) Run() error {
} }
// no more output values are coming... // no more output values are coming...
obj.Logf("func `%s` stopped", node) 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) }(vertex)
} }