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

switch to tsm loader - #PLAT-853 #713

Merged
merged 1 commit into from Aug 22, 2022

Conversation

gvelez17
Copy link
Contributor

switch from esm to tsm loader - #PLAT-853

Description

The CAS api node failed to run in dev with the error Error [ERR_LOADER_CHAIN_INCOMPLETE]: "ts-node/esm 'resolve'" did not call the next hook in its chain

@ukstv suggested switching to TSM loader to avoid this issue. See https://linear.app/3boxlabs/issue/PLAT-853/consider-moving-from-ts-node-to-tsm for further details.

How Has This Been Tested?

Able to run npm run start after switching to tsm loader locally. Need to test on dev, should we test by another method than deploying to dev?

  • Test A (e.g. Test A - New test that ... ran in local, docker, and dev unstable.)
  • Test B

Definition of Done

Before submitting this PR, please make sure:

  • The work addresses the description and outcomes in the issue
  • I have added relevant tests for new or updated functionality
  • My code follows conventions, is well commented, and easy to understand
  • My code builds and tests pass without any errors or warnings
  • I have tagged the relevant reviewers
  • I have updated the READMEs of affected packages
  • I have made corresponding changes to the documentation
  • The changes have been communicated to interested parties

References:

Please list relevant documentation (e.g. tech specs, articles, related work etc.) relevant to this change, and note if the documentation has been updated.

@linear
Copy link

linear bot commented Aug 19, 2022

PLAT-853 consider moving from ts-node to TSM

Description

see TypeStrong/ts-node#1839 (comment)

re the error

> node --loader ts-node/esm ./build/main.js
(node:35) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Error [ERR_LOADER_CHAIN_INCOMPLETE]: "ts-node/esm 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
    at new NodeError (node:internal/errors:387:5)
    at ESMLoader.resolve (node:internal/modules/esm/loader:852:13)
    at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:7)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12) {
  code: 'ERR_LOADER_CHAIN_INCOMPLETE'
}

that appeared on dev cas api (node failed to run)

https://us-east-2.console.aws.amazon.com/cloudwatch/home?region=us-east-2#logsV2:log-groups/log-group/$252Fecs$252Fceramic-dev-cas/log-events/cas_api$252Fcas_api$252F03133c7301494a9ab3d4f4491067747c

@Sergey suggested to switch to TSM

https://github.com/lukeed/tsm/blob/master/docs/usage.md

do we want to do this, and if so we should do it soon?

Technical Information

If required provide a technical explanation of the work.

@gvelez17
Copy link
Contributor Author

gvelez17 commented Aug 19, 2022

(note did not remove the ts-node package from package.json because typeorm still uses it)

@v-stickykeys
Copy link
Contributor

I just tested this with docker-compose as well and sees to fix the issue

This fails using ts-node/esm

ceramic-anchor-service-cas_api-1   | > ceramic-anchor-service@0.0.67 start
ceramic-anchor-service-cas_api-1   | > node --loader ts-node/esm ./build/main.js
ceramic-anchor-service-cas_api-1   | 
ceramic-anchor-service-cas_api-1   | (node:23) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
ceramic-anchor-service-cas_api-1   | (Use `node --trace-warnings ...` to show where the warning was created)
ceramic-anchor-service-cas_api-1   | Error [ERR_LOADER_CHAIN_INCOMPLETE]: "ts-node/esm 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
ceramic-anchor-service-cas_api-1   |     at new NodeError (node:internal/errors:387:5)
ceramic-anchor-service-cas_api-1   |     at ESMLoader.resolve (node:internal/modules/esm/loader:852:13)
ceramic-anchor-service-cas_api-1   |     at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:7)
ceramic-anchor-service-cas_api-1   |     at async Promise.all (index 0)
ceramic-anchor-service-cas_api-1   |     at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
ceramic-anchor-service-cas_api-1   |     at async loadESM (node:internal/process/esm_loader:91:5)
ceramic-anchor-service-cas_api-1   |     at async handleMainPromise (node:internal/modules/run_main:65:12) {
ceramic-anchor-service-cas_api-1   |   code: 'ERR_LOADER_CHAIN_INCOMPLETE'
ceramic-anchor-service-cas_api-1   | }

This works using tsm

ceramic-anchor-service-cas_api-1   | > ceramic-anchor-service@0.0.67 start
ceramic-anchor-service-cas_api-1   | > node --loader tsm ./build/main.js
ceramic-anchor-service-cas_api-1   | 
ceramic-anchor-service-cas_api-1   | (node:21) ExperimentalWarning: Custom ESM Loaders is an experimental feature. This feature could change at any time
ceramic-anchor-service-cas_api-1   | (Use `node --trace-warnings ...` to show where the warning was created)
ceramic-anchor-service-cas_api-1   | (node:21) DeprecationWarning: Obsolete loader hook(s) supplied and will be ignored: getFormat, transformSource
ceramic-anchor-service-cas_api-1   | [2022-08-22T17:01:33.034Z] IMPORTANT: 'Connecting to database...'
ceramic-anchor-service-cas_api-1   | [2022-08-22T17:01:33.583Z] IMPORTANT: 'Connected to database: default'
ceramic-anchor-service-cas_api-1   | [2022-08-22T17:01:33.585Z] IMPORTANT: 'Starting Ceramic Anchor Service at version 0.0.67 with config:\n' +

Copy link
Contributor

@ukstv ukstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏇

@ukstv
Copy link
Contributor

ukstv commented Aug 22, 2022

APPROVE

@gvelez17 gvelez17 merged commit 585e086 into develop Aug 22, 2022
@gvelez17 gvelez17 deleted the feat/switch-to-tsm-from-esm-loader branch August 22, 2022 19:20
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.

None yet

4 participants