Skip to content

Revert "fix: investigate memory usage and bundle size"#5766

Merged
maidul98 merged 1 commit intomainfrom
revert-5692-tre/eng-4694-investigate-memory
Mar 20, 2026
Merged

Revert "fix: investigate memory usage and bundle size"#5766
maidul98 merged 1 commit intomainfrom
revert-5692-tre/eng-4694-investigate-memory

Conversation

@maidul98
Copy link
Copy Markdown
Collaborator

Reverts #5692

@linear
Copy link
Copy Markdown

linear bot commented Mar 20, 2026

@maidul98 maidul98 merged commit 2c0eab3 into main Mar 20, 2026
7 of 10 checks passed
@maidul98
Copy link
Copy Markdown
Collaborator Author

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 20, 2026

Greptile Summary

This PR reverts #5692 ("fix: investigate memory usage and bundle size"), undoing optimizations that split the bundled oci-sdk into individual sub-packages and changed AWS SDK imports from the full AWS object to service-specific clients (e.g., aws-sdk/clients/ssm). The revert restores the original import patterns and re-consolidates the OCI and AWS dependencies. While the functional behavior is mostly equivalent, the revert introduces three concerns worth addressing before merging:

  • ts-node, tsconfig-paths, and ora are now production dependencies — these are development/CLI tools. All production migration scripts operate on pre-compiled ./dist/ output and do not need ts-node or tsconfig-paths at runtime. ora is a terminal spinner with no production utility. Including them in dependencies increases every production install unnecessarily.
  • getAwsConnectionConfig now returns new AWS.Config({...}) instead of a plain { region, credentials } object. This propagates AWS.Credentials | null (a v2 type) into callers that pass credentials to AWS SDK v3 clients (Route53Client, ACMPCAClient, SecretsManagerClient), forcing non-null ! assertions in three different files to suppress TypeScript errors and effectively bypassing the type system for those credential hand-offs.
  • Two-step SSM credential injection in integration-sync-secret.ts — constructing SSM without credentials and then calling ssm.config.update(config) with an AWS.Config instance is fragile and harder to audit than passing credentials directly in the constructor.

Confidence Score: 3/5

  • Safe to merge for functionality, but the dependency placement issues and credential type mismatches should be addressed before this ships to production.
  • The revert restores code that was working prior to fix: investigate memory usage and bundle size #5692, so there is no new functional risk. However, the revert inadvertently promotes three dev-only packages (ts-node, tsconfig-paths, ora) to production dependencies and introduces non-null credential assertions that bypass TypeScript safety in multiple AWS SDK v3 call-sites. These are correctness and hygiene issues that warrant a follow-up fix rather than a clean merge.
  • backend/package.json (production dep placement), backend/src/services/app-connection/aws/aws-connection-fns.ts (return type change), and the three files using config.credentials! (route54.ts, aws-pca-certificate-authority-fns.ts, aws-secrets-manager-sync-fns.ts).

Important Files Changed

Filename Overview
backend/package.json Reverts OCI SDK from individual sub-packages back to the bundled oci-sdk; moves ts-node, tsconfig-paths, and ora from devDependencies to production dependencies — adding unnecessary runtime overhead.
backend/src/services/app-connection/aws/aws-connection-fns.ts Changes return type of getAwsConnectionConfig from a plain { region, credentials } object to an AWS.Config instance, causing downstream callers that pass config.credentials to AWS SDK v3 clients to require non-null assertions.
backend/src/services/integration-auth/integration-sync-secret.ts Reverts SSM initialization to a two-step pattern: creates SSM without credentials, then applies them via ssm.config.update(config) — less clean than direct constructor injection but functionally equivalent.
backend/src/services/certificate-authority/acme/dns-providers/route54.ts Adds non-null assertion (config.credentials!) when passing v2 AWS credentials to the v3 Route53Client, masking a type mismatch caused by the changed return type of getAwsConnectionConfig.
backend/src/services/certificate-authority/aws-pca/aws-pca-certificate-authority-fns.ts Adds credentials: awsConfig.credentials! non-null assertion when passing credentials to the v3 ACMPCAClient, same pattern as route54.ts.
backend/src/services/secret-sync/aws-secrets-manager/aws-secrets-manager-sync-fns.ts Adds credentials: config.credentials! non-null assertion when initializing the v3 SecretsManagerClient — same downstream consequence of getAwsConnectionConfig now returning AWS.Config.

Last reviewed commit: "Revert "fix: investi..."

Comment on lines +259 to +260
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Development tools in production dependencies

ts-node and tsconfig-paths are TypeScript compilation tools that have no role in the production server binary. All production scripts (e.g., migration:latest, auditlog-migration:latest) already operate on pre-compiled ./dist/... output and do not invoke ts-node at runtime. Only the -dev migration scripts (e.g., migration:latest-dev) run directly from TypeScript sources and need ts-node.

Including them in dependencies increases the production node_modules install size for every deployment. They should remain in devDependencies — and the eslint import/no-extraneous-dependencies disable comment should be restored in auditlog-knexfile.ts to reflect their dev-only status, exactly as it was before PR #5692.

Suggested change
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
},
"dependencies": {

(Remove ts-node and tsconfig-paths from dependencies and move them back to devDependencies.)

"oci-sdk": "^2.108.0",
"odbc": "^2.4.9",
"openid-client": "^5.6.5",
"ora": "^7.0.1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 CLI spinner library in production dependencies

ora is a terminal spinner library intended for interactive CLI tooling. It has no role in a production Fastify/Node.js server and will only inflate the production node_modules footprint. It should be placed (or kept) in devDependencies.

Comment on lines +78 to +85
return new AWS.Config({
region,
credentials: {
accessKeyId,
secretAccessKey,
sessionToken
}
};
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Return type mismatch causes non-null assertions throughout callers

getAwsConnectionConfig now returns new AWS.Config({...}) (an AWS SDK v2 config object) instead of a plain { region, credentials } literal. AWS.Config.credentials has the TypeScript type AWS.Credentials | null, so every downstream caller that passes config.credentials to an AWS SDK v3 client (Route53Client, ACMPCAClient, SecretsManagerClient) must suppress the resulting type error with a ! non-null assertion.

The ! assertions hide the real issue: the AWS SDK v2 AWS.Credentials instance is subtly different from the AwsCredentialIdentity ({ accessKeyId, secretAccessKey, sessionToken? }) that v3 clients expect. While v3 will fall back to reading the plain properties and this works in practice, the type mismatch means TypeScript's safety net is disabled for those call-sites.

Returning a plain object keeps the API clean and compatible with both SDK generations:

return {
  region,
  credentials: {
    accessKeyId,
    secretAccessKey,
    sessionToken
  }
};

This avoids the need for ! assertions in route54.ts, aws-pca-certificate-authority-fns.ts, and aws-secrets-manager-sync-fns.ts.

Comment on lines 830 to +843
@@ -838,8 +836,14 @@ const syncSecretsAWSParameterStore = async ({
}
});

const ssm = new AWS.SSM({
apiVersion: "2014-11-06",
region: integration.region as string
});
ssm.config.update(config);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Two-step credential injection is fragile and unnecessary

The SSM client is constructed without credentials and they are applied afterwards via ssm.config.update(config) where config is an AWS.Config instance. AWS.Config.prototype.update() accepts AWS.ConfigurationOptions, not another AWS.Config object, so this relies on duck-typing to copy properties over.

This two-step pattern is harder to reason about and makes it non-obvious that the SSM calls below will authenticate correctly. Passing credentials directly in the constructor — as was done in PR #5692 — is cleaner and more explicit:

const ssm = new AWS.SSM({
  apiVersion: "2014-11-06",
  region: integration.region as string,
  credentials: {
    accessKeyId,
    secretAccessKey,
    sessionToken
  }
});

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

1 participant