`_enforceNoReturnValue.js` does not allow for async lifecycle hooks
OpenUI5 version: latest, 1.120 LTS
URL (minimal example if possible):
https://github.com/dfenerski/ui5-async-controller-lifecycle-issue
Steps to reproduce the problem:
The addition of the _enforceNoReturnValue module here 6f52e5142b2c18b2e3f38b4b053e43a9b957edb3 now logs a "future fatal" whenever a lifecycle hook with return value different than undefined is detected. But async functions always return a Promise. Therefore this change disables the possibility to use async lifecycle hooks.
What is the expected result? Async lifecycle hooks are OK
What happens instead?
Log.js?eval:499 2024-03-25 14:30:08.586099 [FUTURE FATAL] The registered Event Listener 'onInit' must not have a return value. - com.github.dfenerski.issue_async_controller_lifecycle.controller.Main
Screenshot:
Hi @dfenerski,
We recently allowed developers to use the async/await syntax for listeners to control events. However, it is important to note that using async functions within the lifecycle hooks of the framework is still restricted. With this module _enforceNoReturnValue the framework reserves the introduction of a return type in the future. As you pointed out correctly, using async functions would already result in a return value that might conflict with such a later change.
Please see the updated ECMAScript Support page.
Also please have a look at the updated API Reference: sap.ui.core.mvc.Controller#onInit.
Best regards, Tommy
Thanks for the info! I missed the docs - sorry for that
@devtomtom it seems sap.ui.core.mvc.ControllerExtensions are also affected, if they define async onLifecycleEvent in their override section. Should they be mentioned in the support & API reference pages too?
@devtomtom it seems
sap.ui.core.mvc.ControllerExtensions are also affected, if they defineasync onLifecycleEventin theiroverridesection. Should they be mentioned in the support & API reference pages too?
@dfenerski Good point, thanks! Yes, it definitely should be mentioned there too.
Hi all,
I came across this problem by chance because we are getting a similar error in our Build Workzone, standard edition Launchpad and maybe it is related.
We integrate various specially developed cloud apps and on-premise apps into the WorkZone. We are using view mode "Spaces and Pages - New Experience". For a few days now, various errors have been occurring again and again, making it almost impossible to use the Launchpad.
-
Error - Tiles cannot be loaded
-
Error - CSS is not loaded
-
Error - Strange bar appears
The Launchpad uses SAPUI5 version 1.123.1 (built at 2024-04-18T13:07).
Maybe the problem is really related and my input is somehow helpful.
I also raised an issue on me.sap.com: 377725/2024.
Kind regards, Johannes
Hi @thisisevanfox,
the error messages concerning the return value of the hooks shouldn't affect your application. The same is true for the other [FUTURE FATAL] messages... There must be other reasons for the errors described. Can you provide me the URL to the issue you reported
Hi @devtomtom,
see here:
I also raised an issue on me.sap.com: 377725/2024.
Kind regards, Johannes
Closing this issue here. Further updates will be done in the SAP support incident.