When a script action is used in automatic migration, it should be inside of a main(){} function, in other cases, it could cause problems.
CMS-10374 [Search service v2] Non-mandatory long parameters (the return)