Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_enforceNoReturnValue.js does not allow for async lifecycle hooks #4014

Closed
dfenerski opened this issue Mar 25, 2024 · 8 comments
Closed

_enforceNoReturnValue.js does not allow for async lifecycle hooks #4014

dfenerski opened this issue Mar 25, 2024 · 8 comments

Comments

@dfenerski
Copy link
Contributor

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 6f52e51 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:
image

@dfenerski dfenerski changed the title _enforceNoReturnValue.js does not allow for async controller lifecycle hooks _enforceNoReturnValue.js does not allow for async lifecycle hooks Mar 25, 2024
@devtomtom devtomtom self-assigned this Mar 25, 2024
@devtomtom
Copy link
Member

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

@dfenerski
Copy link
Contributor Author

Thanks for the info! I missed the docs - sorry for that

@dfenerski
Copy link
Contributor Author

dfenerski commented Mar 25, 2024

@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
Copy link
Member

@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?

@dfenerski Good point, thanks! Yes, it definitely should be mentioned there too.

@thisisevanfox
Copy link

thisisevanfox commented May 3, 2024

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.

  1. Error - Tiles cannot be loaded
    3-CanNotLoadTile

  2. Error - CSS is not loaded
    1-NoCss

  3. Error - Strange bar appears
    2-Bar

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

@devtomtom
Copy link
Member

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

@thisisevanfox
Copy link

thisisevanfox commented May 7, 2024

Hi @devtomtom,

see here:

I also raised an issue on me.sap.com: 377725/2024.

Kind regards,
Johannes

@flovogt
Copy link
Member

flovogt commented May 13, 2024

Closing this issue here. Further updates will be done in the SAP support incident.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants