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

fix: broken daemon build #170

Merged
merged 12 commits into from
Jun 12, 2024
Merged

fix: broken daemon build #170

merged 12 commits into from
Jun 12, 2024

Conversation

andreabadesso
Copy link
Collaborator

@andreabadesso andreabadesso commented Jun 4, 2024

Motivation

The daemon was failing to load the common module during runtime because the typescript was not being transpiled to javascript. This was not an issue for the lambdas because the wallet-service uses webpack which has a typescript loader

Acceptance Criteria

  • The build script from the daemon should build the common module using its own tsconfig
  • We should have an index file on the common that exposes all methods

Checklist

  • If you are requesting a merge into master, confirm this code is production-ready and can be included in future releases as soon as it gets merged
  • Make sure either the unit tests and/or the QA tests are capable of testing the new features
  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@andreabadesso andreabadesso force-pushed the fix/broken-daemon-build branch 9 times, most recently from fe2078e to 6adf49a Compare June 6, 2024 16:20
@andreabadesso andreabadesso self-assigned this Jun 6, 2024
@andreabadesso andreabadesso added the bug Something isn't working label Jun 6, 2024
Comment on lines -13 to -20
assertEnvVariablesExistence([
'NETWORK',
'APPLICATION_NAME',
'ACCOUNT_ID',
'ALERT_MANAGER_REGION',
'ALERT_MANAGER_TOPIC',
]);

Copy link
Collaborator Author

@andreabadesso andreabadesso Jun 7, 2024

Choose a reason for hiding this comment

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

We have a config method that already checks for those variables and this check shouldn't be in a lib

Comment on lines +13 to +15
"references": [
{ "path": "../../node_modules/@wallet-service/common" }
],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This makes tsconfig compile the common module tsconfig

Copy link

Choose a reason for hiding this comment

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

question(non-blocking): Should we add these instructions to a document on the repository itself?

There seem to be many of those small details that can break the production environment and delay future maintenance releases if left unchecked.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just found out that typescript implements its own JSON parser, which allows for comments in JSON

Added a comment in tsconfig.json in 536ee04

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also created an issue so we document these details better

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

Great! It will surely help with future maintenance

COPY --from=builder /app/packages/daemon/dist .
COPY --from=builder /app/packages/daemon/node_modules ./node_modules
# This will remove all dev dependencies and install production deps only
RUN yarn workspaces focus -A --production
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added the -A flag because otherwise we wouldn't be able to use wallet-lib as a peer dependency and would have issues with bitcore-lib

This is not installing dependencies from the wallet-service lambdas as we are ignoring its package in .dockerignore

packages/daemon/__tests__/integration/balances.test.ts Outdated Show resolved Hide resolved
packages/daemon/package.json Outdated Show resolved Hide resolved
Comment on lines +13 to +15
"references": [
{ "path": "../../node_modules/@wallet-service/common" }
],
Copy link

Choose a reason for hiding this comment

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

question(non-blocking): Should we add these instructions to a document on the repository itself?

There seem to be many of those small details that can break the production environment and delay future maintenance releases if left unchecked.

Dockerfile Outdated
@@ -20,18 +19,11 @@ RUN corepack enable
RUN yarn set version 4.1.0

# This will install dependencies for the sync-daemon, devDependencies included:
Copy link
Member

Choose a reason for hiding this comment

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

Is this comment still valid?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, updated in 3e1a48f

Thanks

@andreabadesso andreabadesso merged commit 7af62c2 into master Jun 12, 2024
1 check passed
@andreabadesso andreabadesso deleted the fix/broken-daemon-build branch June 12, 2024 20:14
This was referenced Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants