Skip to content

Conversation

@najamansari
Copy link

Fix for #410.

Module loading is moved to service/src/util/module-loader.ts. This change has
been applied to all three runners (unified, API, sync).

Tests for the module loader have been added in service/test/src/util/module-loader.test.ts.

Done in response to powersync-ja#410. Refactors module loading to dynamically import
database connection and storage modules (MySQL, PostgreSQL) based on the
configuration, rather than registering them all upfront.

Signed-off-by: Najam Ahmed Ansari <ahmed.najamansari@gmail.com>
@changeset-bot
Copy link

changeset-bot bot commented Nov 27, 2025

🦋 Changeset detected

Latest commit: b4b1923

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@powersync/service-image Minor
@powersync/service-core Minor
@powersync/service-schema Minor
@powersync/service-core-tests Patch
@powersync/service-module-core Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
test-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Nov 27, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

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

Could you confirm whether this approach actually helps to reduce memory usage?

@najamansari
Copy link
Author

@rkistner Thanks for taking a look! Yes there's definitely a little improvement when running the server against MongoDB in my fix vs the main branch baseline.

On my branch:

10 s 60 s 600 s
Total 83642 83980 84730
Code 16246 16562 17219
Strings 16377 16377 16398

On the baseline (main branch):

10 s 60 s 600 s
Total 95833 96108 96923
Code 18050 18309 19028
Strings 23952 23952 23973

During both sets of tests I spun up fresh DB/BE/UI containers via Docker compose, started powersync-server via entry.ts in unified runner mode (default) and took snapshots at the 10/60/600 second marks. During this time, I opened up the todo app UI in two different browser windows and made small operations in each (creating a list, adding tasks to a list).

najamansari and others added 6 commits November 29, 2025 18:36
- Split modules between storage and connection.
- Cleaner code that now checks if given connection/storage types can be handled
  by us or not.
- Error raised if any connection types cannot be handled or if any imports fail.
- Explicit test case that simulates import failure for a module.

Signed-off-by: Najam Ahmed Ansari <ahmed.najamansari@gmail.com>
Signed-off-by: Najam Ahmed Ansari <ahmed.najamansari@gmail.com>
rkistner
rkistner previously approved these changes Dec 4, 2025
Rentacookie
Rentacookie previously approved these changes Dec 4, 2025
@rkistner rkistner dismissed stale reviews from Rentacookie and themself via b4b1923 December 4, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants