matrix-org / matrix-org/matrix-js-sdk
`@matrix-org/matrix-sdk-crypto-wasm' does not provide an export named 'CollectStrategy'` when calling `client.initRustCrypto()` (Node)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.2k
- Forks
- 704
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 40
Description
Hello,
I'm trying to write a Matrix bot in Node. I've got everything working, except the encryption. I followed the docs, but when I'm trying to call `client.initRustCrypto()`, I'm getting the following error in the console:
```
file:///Users/petercherm/Git/pcherm/matrix-securityspy-bot/node_modules/matrix-js-sdk/lib/rust-crypto/RoomEncryptor.js:20
import { CollectStrategy, EncryptionAlgorithm, EncryptionSettings, HistoryVisibility as RustHistoryVisibility, RoomId, UserId } from "@matrix-org/matrix-sdk-crypto-wasm";
^^^^^^^^^^^^^^^
SyntaxError: The requested module '@matrix-org/matrix-sdk-crypto-wasm' does not provide an export named 'CollectStrategy'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:180:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:263:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:547:26)
```
I've got `type: module` in my package.json and also the following options in my `tsconfig.json`:
```
"target": "es2022"
"module": "NodeNext"
"moduleResolution": "nodenext"
```
I tried adding `--experimental-wasm-modules --conditions=wasm-esm` flags to `node`, but to no avail 😕
`npm list matrix-js-sdk @matrix-org/matrix-sdk-crypto-wasm` reports the following versions:
└─┬ matrix-js-sdk@36.0.0
└── @matrix-org/matrix-sdk-crypto-wasm@12.1.0
which I think is correct. I'm on `Node v22.13.0`
Does anyone have any idea why I might be getting that error?
Many thanks in advance.
Peter.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/rust-crypto/RoomEncryptor.js and the client.initRustCrypto() entry point, then inspect the exports provided by @matrix-org/matrix-sdk-crypto-wasm@12.1.0 under Node v22.13.0. Reproduce the import failure with the reported matrix-js-sdk@36.0.0 dependency versions; done means identifying the package or version compatibility issue and documenting or validating the required correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript, wasm
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100