Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Credo Backchannel to ESM and Ts.ED v7 from v6 #889

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nodlesh
Copy link
Contributor

@nodlesh nodlesh commented Dec 6, 2024

This PR attempts to solve the Require ESM errors that occasionally happen in the running of the Credo-ts backchannel. This PR moves the project from a module type of CommonJS to ESNext, while updating some packages as well. Essentially this is moving Ts.ED from v6 to v7, setup for a future move to v8.

This is the original error attempted to resolve,

Starting Credo agent ...
yarn run v1.22.22
$ /src/node_modules/.bin/ts-node src/index.ts -p 9030 -i false
/src/node_modules/@tsed/common/lib/cjs/exports.js:5
require("@tsed/logger");
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /src/node_modules/@tsed/logger/lib/esm/index.js from /src/node_modules/@tsed/common/lib/cjs/exports.js not supported.
Instead change the require of index.js in /src/node_modules/@tsed/common/lib/cjs/exports.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/src/node_modules/@tsed/common/lib/cjs/exports.js:5:1) {
  code: 'ERR_REQUIRE_ESM'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Closes #888

@nodlesh nodlesh self-assigned this Dec 6, 2024
@nodlesh
Copy link
Contributor Author

nodlesh commented Dec 6, 2024

The solution in this PR is currently not working and produces the following error when running the credo agent/backchannel.

Starting Credo agent ...
yarn run v1.22.22
$ /src/node_modules/.bin/tsx src/index.ts -p 9030 -i false
[2024-12-06T14:32:42.452] [WARN ] [TSED] - The 'DifPresentationExchangeModule' module is experimental and could have unexpected breaking changes. When using this module, make sure to use strict versions for all @credo-ts packages.
[2024-12-06T14:32:42.453] [WARN ] [TSED] - The 'SdJwtVc' module is experimental and could have unexpected breaking changes. When using this module, make sure to use strict versions for all @credo-ts packages.
[2024-12-06T14:32:42.454] [WARN ] [TSED] - The 'X509' module is experimental and could have unexpected breaking changes. When using this module, make sure to use strict versions for all @credo-ts packages.
[2024-12-06T14:32:42.454] [WARN ] [TSED] - The 'Mdoc' module is experimental and could have unexpected breaking changes. When using this module, make sure to use strict versions for all @credo-ts packages.
[2024-12-06T14:32:42.455] [INFO ] [TSED] - Creating agent with config {
  agentConfig: {
    label: 'Credo Bob',
    walletConfig: {
      id: 'aath-credo-1733495562441',
      key: '[*****]',
      storage: { credentials: undefined }
    },
    endpoints: [ 'http://host.docker.internal:9031' ],
    useDidSovPrefixWhereAllowed: true,
    logger: 2,
    agentDependencies: true
  }
}
[2024-12-06T14:32:42.460] [INFO ] [TSED] - Initializing wallet 'aath-credo-1733495562441' {
  id: 'aath-credo-1733495562441',
  key: '[*****]',
  storage: { credentials: undefined }
}
[2024-12-06T14:32:42.515] [DEBUG] [TSED] - Wallet 'aath-credo-1733495562441' not found
[2024-12-06T14:32:42.515] [DEBUG] [TSED] - Creating wallet 'aath-credo-1733495562441
[2024-12-06T14:32:43.131] [DEBUG] [TSED] - Successfully created wallet 'aath-credo-1733495562441'
[2024-12-06T14:32:43.132] [DEBUG] [TSED] - Setting current agent storage version to 0.5
[2024-12-06T14:32:43.140] [DEBUG] [TSED] - Storage upgrade record does not exist yet. Creating.
[2024-12-06T14:32:43.155] [INFO ] [TSED] - Agent storage is up to date.
[2024-12-06T14:32:43.155] [DEBUG] [TSED] - Starting HTTP inbound transport { port: 9031 }
[2024-12-06T14:32:43.157] [DEBUG] [TSED] - Starting HTTP outbound transport
[2024-12-06T14:32:43.158] [DEBUG] [TSED] - Mediator routing record not loaded yet, retrieving from storage
[2024-12-06T14:32:43.159] [DEBUG] [TSED] - Mediator routing record does not exist yet, creating routing keys and record
[2024-12-06T14:32:43.213] [DEBUG] [TSED] - Start server...
[2024-12-06T14:32:43.290] [INFO ] [TSED] - Injector created... +6ms
[2024-12-06T14:32:43.290] [INFO ] [TSED] - Build providers +0ms
[2024-12-06T14:32:43.295] [ERROR] [TSED] - UNDEFINED_TOKEN_ERROR: Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?
    at InjectorService.mapInvokeOptions (/src/node_modules/@tsed/di/src/services/InjectorService.ts:679:13)
    at InjectorService.resolve (/src/node_modules/@tsed/di/src/services/InjectorService.ts:610:31)
    at InjectorService.invoke (/src/node_modules/@tsed/di/src/services/InjectorService.ts:228:23)
    at resolver (/src/node_modules/@tsed/di/src/decorators/inject.ts:80:31)
    at InjectorService.bindProperty (/src/node_modules/@tsed/di/src/services/InjectorService.ts:435:11)
    at <anonymous> (/src/node_modules/@tsed/di/src/services/InjectorService.ts:401:16)
    at Array.forEach (<anonymous>)
    at InjectorService.bindInjectableProperties (/src/node_modules/@tsed/di/src/services/InjectorService.ts:398:31)
    at InjectorService.resolve (/src/node_modules/@tsed/di/src/services/InjectorService.ts:660:12)
    at InjectorService.invoke (/src/node_modules/@tsed/di/src/services/InjectorService.ts:237:21)
node:internal/process/promises:391
    triggerUncaughtException(err, true /* fromPromise */);
    ^

UNDEFINED_TOKEN_ERROR: Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?
    at InjectorService.mapInvokeOptions (/src/node_modules/@tsed/di/src/services/InjectorService.ts:679:13)
    at InjectorService.resolve (/src/node_modules/@tsed/di/src/services/InjectorService.ts:610:31)
    at InjectorService.invoke (/src/node_modules/@tsed/di/src/services/InjectorService.ts:228:23)
    at resolver (/src/node_modules/@tsed/di/src/decorators/inject.ts:80:31)
    at InjectorService.bindProperty (/src/node_modules/@tsed/di/src/services/InjectorService.ts:435:11)
    at <anonymous> (/src/node_modules/@tsed/di/src/services/InjectorService.ts:401:16)
    at Array.forEach (<anonymous>)
    at InjectorService.bindInjectableProperties (/src/node_modules/@tsed/di/src/services/InjectorService.ts:398:31)
    at InjectorService.resolve (/src/node_modules/@tsed/di/src/services/InjectorService.ts:660:12)
    at InjectorService.invoke (/src/node_modules/@tsed/di/src/services/InjectorService.ts:237:21)

Node.js v20.18.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any help solving the above error would be greatly appreciated.

If you get the code form this branch, you can see the error by running

./manage rebuild -a credo
LEDGER_URL_CONFIG=http://test.bcovrin.vonx.io TAILS_SERVER_URL_CONFIG=https://tails.vonx.io ./manage start -b credo

@swcurran
Copy link
Contributor

swcurran commented Dec 6, 2024

Lots of stuff! Ran it locally and still no luck - Acme timed out again.

@nodlesh
Copy link
Contributor Author

nodlesh commented Dec 6, 2024

This is in draft, so it won't work. This PR right now is a call for help. I'm making a post on the Credo Discord.

Signed-off-by: Sheldon Regular <[email protected]>
Signed-off-by: Sheldon Regular <[email protected]>
@nodlesh nodlesh force-pushed the fix/credo-agent-run-failure branch from 7a39c84 to b1055eb Compare December 13, 2024 22:02
@nodlesh
Copy link
Contributor Author

nodlesh commented Dec 13, 2024

This PR will remain in Draft and put aside for now. Working with the Ts.ED maintainers still hasn't come to a resolution on the UNDEFINED_TOKEN_ERROR above.

Some references for a future reattempt at this.

@nodlesh nodlesh changed the title Fix require() of ES Module Errors Migrate Backchannel to ESM Module and Ts.ED v7 from v6 Dec 13, 2024
@nodlesh nodlesh changed the title Migrate Backchannel to ESM Module and Ts.ED v7 from v6 Migrate Credo Backchannel to ESM and Ts.ED v7 from v6 Dec 13, 2024
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.

Credo agent failing to start
2 participants