question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move from deferred to async ModuleApi methods

See original GitHub issue

Description:

Currently some methods of the ModuleApi are still defer coroutines instead of async defs, such as e.g. check_user_exists and register_user, even tho they really are just wrappers with no additional logic. Since the ModuleApi is slowly moving to mostly async, it’d be great to have those methods be async as well, so modules no longer need a deferred wrapper.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
johannescpkcommented, Sep 30, 2022

You are right. I tested by modifying just that call and it works. Not sure what went wrong in https://github.com/matrix-org/synapse/issues/13948#issuecomment-1263649890, probably something else I changed while refactoring the calls.

Thanks for your patience & help.

1reaction
johannescpkcommented, Sep 30, 2022

I think modules should generally be able to just call these methods as if they’re async though and await them like normal?

Oooh, turns out you’re right. It works by just awaiting the methods. In this case the issue could also be closed since that allows me to just use the public ModuleApi methods. Sorry for the noise.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Efficiently load JavaScript with defer and async - Flavio Copes
async blocks the parsing of the page while defer does not. Blocking rendering. Neither async nor defer guarantee anything on blocking rendering. This...
Read more >
Scripts: async, defer - The Modern JavaScript Tutorial
In practice, defer is used for scripts that need the whole DOM and/or their relative execution order is important. And async is used...
Read more >
javascript - Script Tag - async & defer - Stack Overflow
Async scripts are executed as soon as the script is loaded, so it doesn't guarantee the order of execution (a script you included...
Read more >
goog.async.Deferred - Google
A Deferred represents the result of an asynchronous operation. A Deferred instance has no result when it is created, and is "fired" (given...
Read more >
deferred.promise() | jQuery API Documentation
The deferred.promise() method allows an asynchronous function to prevent other code from interfering with the progress or status of its internal request.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found