Why does wait return 127 only if lastpipe is enabled?

I don’t understand why wait returns 127 in this case. According to the manpage, this happens if the subprocess does not exist anymore. This seems to not be the case.

This is the minimal example:

#!/usr/bin/env bash

shopt -s lastpipe                                                                           

echo text | {                                                                               
    tr a-z A-Z <&0 &
    wait -n -f 
}
echo Exit code: $?

It works as expected if lastpipe is not enabled.

Why is that? It’s really getting me down.

Below is a more sophisticated example showing the same issue for try1(), but it works for try2():

#!/usr/bin/env bash

execute() (                                                                                 
    if $BACKGROUND; then                                                                    
        "$@" <&0 &                                                                          
        wait -n -f
    else
        "$@"                                                                                
    fi  
)

try1() {
    echo try1 |                                                                             
    execute tr a-z A-Z                                                                      
}

try2() {
    execute tr a-z A-Z < <(echo try2)                                                       
}

testIt() {
    echo                                                                                    
    echo "BACKGROUND=$BACKGROUND"                                                           
    for TRY in try1 try2; do
        $TRY
        echo $?
    done
}

shopt -s lastpipe

BACKGROUND=true  testIt
BACKGROUND=false testIt