Skip to content

Fix backend CI test crash caused by service initialization import cycle#6

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

Fix backend CI test crash caused by service initialization import cycle#6
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-failing-github-actions-job-again

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The Tests (backend + contract) workflow was failing in the backend Jest phase due to a module initialization error in the auth test path. The failure was caused by an ES module import cycle that triggered a temporal-dead-zone access of hipaaComplianceService during bootstrap.

  • Root cause

    • apiService imported secureStorageService at module load.
    • secureStorageService transitively depended on hipaaComplianceService, which imports apiService.
    • This cycle surfaced as ReferenceError: Cannot access 'hipaaComplianceService' before initialization.
  • Change made (surgical)

    • Removed eager secureStorageService import from server/services/apiService.js.
    • Switched handleFileUpload to lazy-load secureStorageService at call time.
    • Added module-level promise caching so repeated/concurrent uploads reuse one import resolution.
  • Behavioral impact

    • Breaks bootstrap-time circular initialization without changing upload semantics.
    • File upload path still initializes storage service on demand before uploadToIPFS.
let secureStorageServiceModulePromise = null;

async handleFileUpload(file, options = {}) {
  if (!secureStorageServiceModulePromise) {
    secureStorageServiceModulePromise = import("./secureStorageService.js");
  }
  const { default: secureStorageService } =
    await secureStorageServiceModulePromise;

  if (!secureStorageService.initialized) {
    await secureStorageService.initialize();
  }

  return secureStorageService.uploadToIPFS(file);
}

@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:50am

Copilot AI changed the title [WIP] Fix failing GitHub Actions job Tests (backend + contract) Fix backend CI test crash caused by service initialization import cycle Jun 9, 2026
Copilot finished work on behalf of EPW80 June 9, 2026 05:49
Copilot AI requested a review from EPW80 June 9, 2026 05:49
@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