Skip to content

Runtime issue related to using credo from ESM project #2607

@Patrik-Stas

Description

@Patrik-Stas

Creating isolated issue for issue discovered as part of #2579

When project is using ESM modules and credo, it leads to runtime issues.

For reproduction checkout commit 13df6845bc4dc8c1671bf00698deed1658d10473 from repo https://github.com/Patrik-Stas/tsx-credo-06-reproduction/tree/main

If you run pnpm run test you should see in output

[ERROR] DID not created, didCreateResult: {
  "didDocumentMetadata": {},
  "didRegistrationMetadata": {},
  "didState": {
    "state": "failed",
    "reason": "unknownError: Error creating key"
  }
}
[ERROR] ❌ Script failed with error

but if you remove type: module it will succeed

[INFO] ✅ DID key created successfully
[INFO]   DID: did:key:z6MkfnXzhM8iivsgd9774ZHCqKcXDkBEVnY9jwb2BQUFWqfH
[INFO]   KID: did:key:z6MkfnXzhM8iivsgd9774ZHCqKcXDkBEVnY9jwb2BQUFWqfH#z6MkfnXzhM8iivsgd9774ZHCqKcXDkBEVnY9jwb2BQUFWqfH
[INFO] ✅ Script completed successfully

The repo is using simplest possible agent

    const agent = new Agent({
      config: {
        logger: new SimpleLogger(logLevel),
      },
      dependencies: agentDependencies,
      modules: {
        askar: new AskarModule({
          askar: askar,
          store: {
            id: walletId,
            key: walletKey,
          },
          enableKms: true,
          enableStorage: true, // Use Askar's default SQLite storage
        }),
      },
    });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions