Commit graph

2 commits

Author SHA1 Message Date
c0e38bb990 fix: serialize dynamic imports to prevent race condition on parallel account startup
Problem: When multiple Matrix accounts start in parallel, they all trigger
dynamic imports simultaneously. The Rust native crypto module
(@matrix-org/matrix-sdk-crypto-nodejs) crashes when loaded in parallel.

Solution: Add import-mutex.ts that caches import promises. Concurrent callers
now await the same promise instead of triggering parallel imports.

Files changed:
- NEW: src/matrix/import-mutex.ts - serializedImport() utility
- src/matrix/client/create-client.ts - use importCryptoNodejs()
- src/matrix/client/config.ts - use importCredentials()
2026-02-01 11:31:44 +01:00
8790ba5dad feat: Add multi-account Matrix support
- Modified shared.ts to maintain a Map of clients per accountId
- Each account gets its own Matrix client instance
- Backwards compatible with single-account usage
- resolveMatrixAuth now accepts accountId parameter
- stopSharedClient can stop specific or all accounts

Files changed:
- src/matrix/client/shared.ts (main changes)
- src/matrix/client/config.ts (accountId support)
- src/matrix/accounts.ts (list enabled accounts)
- src/matrix/monitor/index.ts (pass accountId)
- src/types.ts (accounts config type)
2026-02-01 11:06:37 +01:00