Skip to content

Conversation

Copy link

Copilot AI commented Jan 1, 2026

Rate limiting errors from npm APIs were logged as confusing messages like "Error: Error: 200 OK" with no actionable information about which packages failed or why.

Changes

  • Error messages now show actual error details: Log error.message instead of full error objects for readable, informative output
  • Consistent error handling: Catch block in getNpmLastWeekDownloads now sets downloads to 0 for failed packages, matching the non-OK response path
// Before
catch (err) {
  console.error(err);
}

// After  
catch (err) {
  console.error(`Error fetching npm last-week download for ${q}: ${err.message}`);
  q.split(',').forEach(item => packageDLCountMap[item] = 0);
}

The script continues processing remaining plugins when individual API calls fail.

Original prompt

This section details on the original issue you should resolve

<issue_title>Analytics GitHub actions job - rate limiting</issue_title>
<issue_description>### Analysis

Looking at the logs, the majority of the plugins detected on npm are not processed due to rate limiting from the following API: https://api.npmjs.org/downloads/point/last-week/<plugin>. I was able to reproduce the issue as well. The error is currently not logged due to this block of code only logging one of the error codes.

Expected Behavior

All plugins show in analytics

Steps To Reproduce

It happens every time the analytics job runs

Logs

Fetching package details data for homebridge-tuya...
2025-11-24T02:15:59.8238735Z     at fetchPackageDetails (file:///home/runner/work/analytics/analytics/scripts/extractAndStorePluginData.mjs:125:13)
2025-11-24T02:15:59.8240143Z     at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
2025-11-24T02:15:59.8584052Z Error fetching data for homebridge-unifi-access: Error: Error: 200 OK
2025-11-24T02:15:59.8585395Z Fetching package details data for @joshepw/homebridge-switchbot...
2025-11-24T02:15:59.8587752Z     at fetchPackageDetails (file:///home/runner/work/analytics/analytics/scripts/extractAndStorePluginData.mjs:125:13)
2025-11-24T02:15:59.8589560Z     at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
2025-11-24T02:15:59.9455282Z Error fetching data for homebridge-alarmdotcom: Error: Error: 200 OK
2025-11-24T02:15:59.9456470Z Fetching package details data for homebridge-homematic...
2025-11-24T02:15:59.9457946Z     at fetchPackageDetails (file:///home/runner/work/analytics/analytics/scripts/extractAndStorePluginData.mjs:125:13)
2025-11-24T02:15:59.9459671Z     at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
2025-11-24T02:15:59.9695902Z Error fetching data for homebridge-alexa-smarthome: Error: Error: 200 OK
2025-11-24T02:15:59.9697384Z Fetching package details data for @pietrolubini/homebridge-ecoflow...
2025-11-24T02:15:59.9699686Z     at fetchPackageDetails (file:///home/runner/work/analytics/analytics/scripts/extractAndStorePluginData.mjs:125:13)
2025-11-24T02:15:59.9700984Z     at process.processTicksAndRejections (node:internal/process/task_queues:103:5)

Configuration

n/a

Environment

n/a

Process Supervisor

hb-service

Additional Context

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Show actual error messages instead of full error objects
- Ensure failed downloads are set to 0 in catch block
- Make error messages more informative for debugging

Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix rate limiting issue in analytics GitHub actions job Improve error logging for npm API failures in analytics job Jan 1, 2026
Copilot AI requested a review from NorthernMan54 January 1, 2026 21:31
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.

Analytics GitHub actions job - rate limiting

2 participants