fix(gateway): resolve TS2339 heartbeat property error in server-cron.ts#30063
Closed
zakky8 wants to merge 2 commits intoopenclaw:mainfrom
Closed
fix(gateway): resolve TS2339 heartbeat property error in server-cron.ts#30063zakky8 wants to merge 2 commits intoopenclaw:mainfrom
zakky8 wants to merge 2 commits intoopenclaw:mainfrom
Conversation
server-cron.ts line 197 was failing with TS2339 because \�gentEntry\ could be inferred as the boolean \alse\. This adds a runtime check to ensure it is an object before accessing the \.heartbeat\ property.
Contributor
Greptile SummaryFixed TypeScript compilation error (
Confidence Score: 5/5
Last reviewed commit: 9ffc81a |
nikolasdehor
left a comment
There was a problem hiding this comment.
This fixes the correct issue, but PRs #30048 and #30060 also fix the same agentEntry?.heartbeat line. The guard typeof agentEntry === 'object' && agentEntry is more verbose than needed. The ternary approach in #30048 (Array.isArray(...) ? list.find(...) : undefined) is cleaner because it eliminates false from the type at the source. Recommend coordinating with #30048 and #30060 to avoid merge conflicts.
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.
What does this PR do?
Fixes a TypeScript compilation error (
TS2339: Property 'heartbeat' does not exist on type 'false | AgentConfig') insrc/gateway/server-cron.tsthat is currently failing CI on themainbranch.Why is this needed?
On line 197 of
server-cron.ts,agentEntrycan be inferred as the booleanfalsedue to the wayruntimeConfig.agents.list.find()interacts with the type system. Attempting to spread...agentEntry?.heartbeatcausestscto fail.This PR adds a runtime check
typeof agentEntry === "object" && agentEntryto ensureagentEntryis indeed an object before accessing the.heartbeatproperty, satisfying the TypeScript compiler and restoring CI to a passing state.How was it tested?
pnpm exec tsc --noEmitpasses locally without theTS2339error.