Skip to content

Conversation

@geka-evk
Copy link

No description provided.

@geka-evk geka-evk marked this pull request as ready for review November 24, 2025 14:06
@geka-evk geka-evk requested a review from Copilot November 24, 2025 14:06
Copilot finished reviewing on behalf of geka-evk November 24, 2025 14:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates various dependencies and refactors MongoDB and Kafka service implementations to improve connection management, error handling, and logging. The changes include upgrading to snapshot versions of key dependencies and restructuring how MongoDB connections are maintained throughout the application lifecycle.

  • Refactored MongoDB service to maintain a persistent connection instead of creating/closing connections for each operation
  • Updated Kafka service to use the new Consumer API from @mojaloop/central-services-stream
  • Improved logging throughout the application using child loggers with component context
  • Added UUID to BSON conversion for MongoDB document IDs

Reviewed changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/unit/services/event-processor.service.test.js Added async/await to initialize test and fixed trailing whitespace issues
src/services/mongo-db.service.js Refactored to use persistent MongoDB connection, added event listeners, improved error handling and logging
src/services/kafka.service.js Updated to use new Consumer API and added logging for consumer startup
src/services/event-processor.service.js Refactored message handling into separate parseOneEvent method, added uuidToBson conversion, improved error logging
src/lib/config.js Standardized format strings, improved code formatting and consistency
src/index.js Reordered imports, improved logging messages, added await for eventProcessor initialization
package.json Updated multiple dependencies including central-services packages, added snapshot version with overrides
eslint.config.js Added Jest globals to ESLint configuration
docker-compose.yaml Updated Kafka image to bitnamilegacy, changed topic name, added LOG_LEVEL environment variable
Dockerfile Commented out test directory copy in build stage
CODEOWNERS Added new code owner @geka-evk
.ncurc.yaml Added configuration for npm-check-updates with rejection reasons for specific packages

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

logger.error(message, err)
} finally {
await mongo.close()
this.log.error('Failed to initialize MongoDB Service: ', err)
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

Potential resource leak: If the MongoDB connection fails during initialization (lines 19-36), the mongoClient connection is not closed. The old code had a finally block that ensured the connection was closed after initialization. Consider adding cleanup logic in the catch block to close the connection if initialization fails:

} catch (err) {
  this.log.error('Failed to initialize MongoDB Service: ', err)
  if (this.mongoClient) {
    await this.mongoClient.close()
    this.mongoClient = null
  }
}
Suggested change
this.log.error('Failed to initialize MongoDB Service: ', err)
this.log.error('Failed to initialize MongoDB Service: ', err)
if (this.mongoClient) {
await this.mongoClient.close()
this.mongoClient = null
}

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

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