Skip to content

Fix backend CI test failure by breaking api/storage service init cycle#5

Closed
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-failing-github-actions-job
Closed

Fix backend CI test failure by breaking api/storage service init cycle#5
Copilot wants to merge 3 commits into
mainfrom
copilot/fix-failing-github-actions-job

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The Tests (backend + contract) workflow was failing in the backend Jest phase with ReferenceError: Cannot access 'hipaaComplianceService' before initialization. The failure was caused by a circular module initialization chain across server services.

  • Root cause eliminated: circular service initialization

    • Removed eager secureStorageService import from server/services/apiService.js.
    • Switched handleFileUpload to lazy-load secureStorageService at call time, avoiding module-load-time recursion:
      • apiService -> secureStorageService -> hipaaComplianceService -> apiService.
  • Import behavior hardened for runtime stability

    • Added a cached module import promise so repeated uploads reuse the same load path.
    • Added failure recovery: if dynamic import fails, cached promise is reset so subsequent calls can retry instead of being stuck in a rejected state.
  • Code shape (representative snippet)

let secureStorageServicePromise;

if (!secureStorageServicePromise) {
  secureStorageServicePromise = import("./secureStorageService.js")
    .then(({ default: service }) => service)
    .catch((error) => {
      secureStorageServicePromise = null;
      throw error;
    });
}
const secureStorageService = await secureStorageServicePromise;

@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
healthmint Ready Ready Preview, Comment Jun 9, 2026 5:37am

Copilot AI changed the title [WIP] Fix the failing GitHub Actions job Tests (backend + contract) Fix backend CI test failure by breaking api/storage service init cycle Jun 9, 2026
Copilot finished work on behalf of EPW80 June 9, 2026 05:36
Copilot AI requested a review from EPW80 June 9, 2026 05:36
@EPW80 EPW80 closed this Jun 9, 2026
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.

2 participants