Skip to content

Address code review feedback: error handling, batching, and type safety#5

Draft
Copilot wants to merge 2 commits intokemarx/upgradefrom
copilot/sub-pr-3
Draft

Address code review feedback: error handling, batching, and type safety#5
Copilot wants to merge 2 commits intokemarx/upgradefrom
copilot/sub-pr-3

Conversation

Copy link

Copilot AI commented Jan 5, 2026

Addressed remaining code review feedback on the redis v4+ migration PR to improve error handling, performance, and type safety.

Changes

  • Error message formatting: Fixed error handler to pass error object directly instead of using invalid ? placeholder

    // Before: self._server.error('Failed to initialize Redis engine: ?', error);
    // After:  self._server.error('Failed to initialize Redis engine:', error);
  • Batch processing for notifications: Added batching (100 clients per batch) to prevent overwhelming Redis when publishing to channels with thousands of subscribers

    var batchSize = 100;
    for (var j = 0; j < clients.length; j += batchSize) {
      var batch = clients.slice(j, j + batchSize);
      await Promise.all(batch.map(notifyClient));
    }
  • Type safety for zScore: Added defensive parsing and NaN checks since Redis clients may return strings or numbers

    var score = await this._redis.zScore(this._ns + '/clients', clientId);
    if (score !== null) {
      score = parseFloat(score);
    }
    var exists = score !== null && !isNaN(score) && /* timestamp check */;
  • Documentation: Enhanced subscribe method comments to clarify memory leak risk if called multiple times on same topic

Security

CodeQL scan: 0 alerts


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ve type safety

Co-authored-by: kirannalla-ms <78442654+kirannalla-ms@users.noreply.github.com>
Copilot AI changed the title [WIP] Upgrade for latest node version Address code review feedback: error handling, batching, and type safety Jan 5, 2026
Copilot AI requested a review from kirannalla-ms January 5, 2026 17:50
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