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)

Open
#4,660 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

O-Occasional S-Major T-Defect
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.