App not launching after completing installation

I have a macOS application. I have also created the pkg installer to install my app. The postflight script in the pkg installer has following code for launching the app as soon as installation finishes.

sudo -u $USER open "/Applications/Test/Test App.app"

This is working fine on macOS Mojave (10.14), Catalina (10.15) and Monterey (12.0).

But, on macOS Big Sur (11.x) it is failing intermittently. This means sometimes app gets launched successfully, but sometimes app is not launched.