Can we move the creation of the trigger promise into the if? I think that creating the trigger in all situation including deployment is not a good precedent.
It should be possible to just define the trigger variable and test wether or not it is defined to handle it later on.