cacti icon indicating copy to clipboard operation
cacti copied to clipboard

fix(api-server): await all gRPC plugin registrations before bindAsync

Open mn-ram opened this issue 8 months ago • 4 comments

Problem

startGrpcServer() used forEach(async ...) to register plugin gRPC services, which does not await async callbacks. This caused bindAsync() to execute before plugins called addService(), resulting in UNIMPLEMENTED errors on all connector gRPC endpoints.

Additionally, plugin initialization failures surfaced as unhandled promise rejections, crashing Node.js ≥ 15.

Fix

  • Replaced forEach(async ...) with await Promise.all(map(async ...))
  • Ensured all plugin services are registered before calling bindAsync()
  • Aligned implementation with createCrpcServicesOfPlugins() pattern

Result

  • Prevents race condition during server startup
  • Ensures all gRPC services are properly registered
  • Avoids unhandled promise rejections

Fixes #4162

mn-ram avatar Mar 31 '26 14:03 mn-ram

Gentle ping for reviews — this fixes a race condition (#4162) where bindAsync() fires before plugins call addService(), causing "UNIMPLEMENTED" errors on gRPC connector endpoints. The fix aligns with the existing createCrpcServicesOfPlugins() pattern.

Would appreciate a second approval. @VRamakrishna @outSH

mn-ram avatar Apr 10 '26 04:04 mn-ram

Please squash the commits into single commit

sandeepnRES avatar Apr 13 '26 10:04 sandeepnRES

@sandeepnRES Done. Squashed all commits into one. Let me know if anything else is needed.

mn-ram avatar Apr 13 '26 12:04 mn-ram

@LordKubaya This PR was already approved earlier. Re-requested review by mistake. No further changes since approval.

mn-ram avatar Apr 13 '26 12:04 mn-ram