Why would this work
timeout 10s echo \"foo bar\" # foo bar
but this wouldn\'t
function echoFooBar { echo \"foo bar\" } e
As Douglas Leeder said you need a separate process for timeout to signal to. Workaround by exporting function to subshells and running subshell manually.
export -f echoFooBar timeout 10s bash -c echoFooBar