Fix MCP feature enumeration with with cap, deadline and per instance fault containement#7841
Merged
Merged
Conversation
…fault containment
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7841 +/- ##
==========================================
+ Coverage 75.12% 75.17% +0.04%
==========================================
Files 430 430
Lines 22863 22886 +23
Branches 6063 6069 +6
==========================================
+ Hits 17176 17204 +28
+ Misses 5687 5682 -5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cstns
approved these changes
Jul 17, 2026
cstns
left a comment
Contributor
There was a problem hiding this comment.
Changes look good to me. One thing I'm unclear about is that since you changed the signature of the /features endpoint, the type drift check didn't fail..
Not going to block it for that thogh
Steve-Mcl
enabled auto-merge (squash)
July 17, 2026 08:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
TL;DR
The
POST /api/v1/expert/mcp/featuresendpoint checked each candidate instance/device for liveness sequentially, so one slow or unreachable instance held up all the others (worst caseN x timeout). It also fetched features via a barePromise.allwith no per-item error handling - and since a device MQTT call rejects on timeout, a single unresponsive device could reject the whole batch and 500 the endpoint.This PR replaces that with a single bounded, pipelined per-instance scan: each instance flows liveness -> token -> features independently under a concurrency limit, wrapped so one failure can never sink the batch. The scan is bounded by a total server cap and an overall deadline, and the response now carries a
summarydescribing coverage. All limits are configurable viaapp.config.expert.insights.*.Details
try..catch, so a rejecting device call is skipped rather than failing the whole request.MAX_SERVERS(default 20); the remainder is reported as unenumerated.ENUM_CONCURRENCY(default 5, aligned with the DB pool).ENUM_DEADLINE_MS(default 10s) returns partial results; in-flight MQTT calls run out their own timeouts (no abort for MQTT).DEVICE_FEATURES_TIMEOUT); liveness stays at 3s.app.config.expert.insights.{ MAX_SERVERS, ENUM_CONCURRENCY, ENUM_DEADLINE_MS, DEVICE_LIVENESS_TIMEOUT, DEVICE_FEATURES_TIMEOUT }, each falling back to the defaults above.summaryin the response (and schema):{ instanceCount, mcpServerCount, enumeratedCount, unenumeratedCount, limit, limited, deadlineReached }.Builds on the recently merged
Device.statusgate, which already skips offline devices before they reach the scan.Tests
test/unit/forge/ee/routes/expert/index_spec.js:summary.buildDeviceRegistrations(count)helper producing N distinct online device registrations for fan-out/cap coverage.summaryreflects the cap (enumeratedCount 20,unenumeratedCount 5,limited true), and instances beyond the cap are never contacted.deadlineReached: true, and failed instances are skipped rather than reported incompatible.Related Issue(s)
closes #7832
Checklist
flowforge.yml?FlowFuse/helmto update ConfigMap TemplateFlowFuse/CloudProjectto update values for Staging/ProductionLabels
area:migrationlabel