Skip to content

fix: investigate memory usage and bundle size#5767

Merged
PrestigePvP merged 2 commits intomainfrom
revert-5766-revert-5692-tre/eng-4694-investigate-memory
Mar 20, 2026
Merged

fix: investigate memory usage and bundle size#5767
PrestigePvP merged 2 commits intomainfrom
revert-5766-revert-5692-tre/eng-4694-investigate-memory

Conversation

@maidul98
Copy link
Copy Markdown
Collaborator

Reverts #5766

@linear
Copy link
Copy Markdown

linear bot commented Mar 20, 2026

@maidul98
Copy link
Copy Markdown
Collaborator Author

maidul98 commented Mar 20, 2026

Snyk checks have failed. 21 issues have been found so far.

Status Scan Engine Critical High Medium Low Total (21)
Open Source Security 1 12 8 0 21 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 reduces backend bundle size and memory footprint by replacing the monolithic oci-sdk package with five targeted OCI sub-packages (oci-common, oci-identity, oci-keymanagement, oci-secrets, oci-vault), removing googleapis (no remaining usages confirmed), and relocating ts-node, tsconfig-paths, and ora from dependencies to devDependencies. The OCI and AWS source-file updates are mechanical import rewrites with no logic changes.

Key concerns:

  • Production migration breakageauditlog-knexfile.ts still contains import "ts-node/register" on line 3. Because tsup is configured with skipNodeModulesBundle: true, this import is emitted verbatim into the compiled dist/db/auditlog-knexfile.mjs. Moving ts-node to devDependencies means it won't be installed in production, so every auditlog migration command (auditlog-migration:latest, auditlog-migration:up, etc.) will throw ERR_MODULE_NOT_FOUND at startup. The import is entirely unnecessary in already-compiled output and should be removed from the source file.
  • Unused type fields in OCI vault sync typesTUpdateOCIVaultVariable, TDeleteOCIVaultVariable, and TUnmarkOCIVaultVariableFromDeletion inherit compartmentId and vaultId from TOCIVaultListVariables, but these fields are never used by the corresponding function implementations, resulting in callers passing dead arguments.

Confidence Score: 3/5

  • Not safe to merge without fixing the ts-node devDependency issue, which will break production audit-log migrations.
  • The OCI and AWS import rewrites are low-risk mechanical changes, but moving ts-node to devDependencies while auditlog-knexfile.ts still imports ts-node/register is a concrete production breakage path — confirmed by the skipNodeModulesBundle: true tsup config that prevents bundling. Fixing that one line would bring confidence to 5.
  • backend/src/db/auditlog-knexfile.ts — the import "ts-node/register" line must be removed or ts-node must be kept in dependencies.

Important Files Changed

Filename Overview
backend/src/db/auditlog-knexfile.ts Still imports ts-node/register at the top level, which will fail in production now that ts-node has been moved to devDependencies and tsup's skipNodeModulesBundle: true keeps it as an external import.
backend/package.json Moves ts-node, tsconfig-paths, and ora to devDependencies, replaces monolithic oci-sdk with individual OCI packages, and removes googleapis. Core refactoring for bundle-size reduction — mostly correct, but moving ts-node to devDependencies conflicts with the auditlog knexfile.
backend/src/ee/services/secret-sync/oci-vault/oci-vault-sync-types.ts OCI vault type definitions updated to use the new granular oci-common package. TUpdateOCIVaultVariable, TDeleteOCIVaultVariable, and TUnmarkOCIVaultVariableFromDeletion all extend TOCIVaultListVariables (which includes compartmentId and vaultId), but those extra fields are unused in the actual function implementations.
backend/src/ee/services/app-connections/oci/oci-connection-fns.ts Successfully migrated from monolithic oci-sdk to individual oci-common, oci-identity, and oci-keymanagement packages with no functional changes.
backend/src/ee/services/secret-sync/oci-vault/oci-vault-sync-fns.ts Updated imports to use individual oci-secrets and oci-vault packages; logic is unchanged and functionally correct.
backend/src/services/pki-sync/aws-certificate-manager/aws-certificate-manager-pki-sync-fns.ts Uses RE2 for regex patterns and aws-sdk v2 ACM client correctly; no new issues detected.

Comments Outside Diff (1)

  1. backend/src/ee/services/secret-sync/oci-vault/oci-vault-sync-types.ts, line 37-48 (link)

    P2 Unused compartmentId and vaultId fields inherited via type extension

    TUpdateOCIVaultVariable, TDeleteOCIVaultVariable, and TUnmarkOCIVaultVariableFromDeletion all extend TOCIVaultListVariables, which includes compartmentId and vaultId. However, the actual function implementations in oci-vault-sync-fns.ts destructure only provider + secretId (+ value for update) and never reference these two inherited fields:

    // oci-vault-sync-fns.ts
    const updateOCIVaultVariable = async ({ provider, secretId, value }: TUpdateOCIVaultVariable) => { ... }
    const deleteOCIVaultVariable = async ({ provider, secretId }: TDeleteOCIVaultVariable) => { ... }
    const unmarkOCIVaultVariableFromDeletion = async ({ provider, secretId }: TUnmarkOCIVaultVariableFromDeletion) => { ... }

    Every call-site passes compartmentId and vaultId even though they are silently discarded. Consider narrowing the types so callers don't have to supply unused arguments:

    export type TUpdateOCIVaultVariable = {
      provider: SimpleAuthenticationDetailsProvider;
      secretId: string;
      value: string;
    };
    
    export type TDeleteOCIVaultVariable = {
      provider: SimpleAuthenticationDetailsProvider;
      secretId: string;
    };
    
    export type TUnmarkOCIVaultVariableFromDeletion = {
      provider: SimpleAuthenticationDetailsProvider;
      secretId: string;
    };

    Rule Used: When using parameters in API calls, ensure they ar... (source)

    Learnt From
    Infisical/infisical#3643

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

@PrestigePvP PrestigePvP merged commit 3da5a59 into main Mar 20, 2026
8 of 10 checks passed
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.

3 participants