Skip to content

Conversation

MadLittleMods
Copy link
Contributor

@MadLittleMods MadLittleMods commented Jul 25, 2025

Resolve breaking change to run_as_background_process in module API

Fix #18735

In #18670, we updated run_as_background_process to add a server_name argument. Because this function is directly exported from the Synapse module API, this is a breaking change to any downstream Synapse modules that use run_as_background_process.

This PR shims and deprecates the existing run_as_background_process(...) for modules by providing a stub server_name value and introduces a new ModuleApi.run_as_background_process(...) that covers the server_name logic automagically.

Dev notes

It looks like we already do this for @cached

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
    • Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
  • Code style is correct (run the linters)

@github-actions github-actions bot deployed to PR Documentation Preview July 25, 2025 19:58 Active
@MadLittleMods MadLittleMods marked this pull request as ready for review July 25, 2025 20:28
@MadLittleMods MadLittleMods requested a review from a team as a code owner July 25, 2025 20:28
@github-actions github-actions bot deployed to PR Documentation Preview July 28, 2025 15:50 Active
@anoadragon453
Copy link
Member

@MadLittleMods out of interest did you see @reivilibre's suggestion here?

@@ -0,0 +1 @@
Deprecate `run_as_background_process` exported as part of the module API interface in favor of `ModuleApi.run_as_background_process`. See the relevant section in the upgrade notes for more information.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MadLittleMods out of interest did you see @reivilibre's suggestion here?

-- @anoadragon453, #18737 (comment)

No. I just solved it how I've been solving it for all of the metrics refactors, passing it in manually.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, given the consistency this makes sense.

Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs look excellent. Just a minor suggestion below, and a git conflict to resolve.

Thanks for taking this on, this looks good to me.

And a definite warning to our future selves to not expose internals directly. Another common one is feeding the result of datastore functions directly back in API responses.

@github-actions github-actions bot deployed to PR Documentation Preview July 29, 2025 18:18 Active
@MadLittleMods MadLittleMods merged commit 31a38f5 into develop Jul 29, 2025
78 of 80 checks passed
@MadLittleMods MadLittleMods deleted the madlittlemods/18735-module-api-run_as_background_process branch July 29, 2025 19:29
@MadLittleMods
Copy link
Contributor Author

Thanks for the review @anoadragon453 🐄

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#18670 is a breaking change to the module API function run_as_background_process

2 participants