Skip to content

fix(gateway): resolve TS2339 heartbeat property error in server-cron.ts#30063

Closed
zakky8 wants to merge 2 commits intoopenclaw:mainfrom
zakky8:fix/server-cron-ts2339
Closed

fix(gateway): resolve TS2339 heartbeat property error in server-cron.ts#30063
zakky8 wants to merge 2 commits intoopenclaw:mainfrom
zakky8:fix/server-cron-ts2339

Conversation

@zakky8
Copy link

@zakky8 zakky8 commented Feb 28, 2026

What does this PR do?

Fixes a TypeScript compilation error (TS2339: Property 'heartbeat' does not exist on type 'false | AgentConfig') in src/gateway/server-cron.ts that is currently failing CI on the main branch.

Why is this needed?

On line 197 of server-cron.ts, agentEntry can be inferred as the boolean false due to the way runtimeConfig.agents.list.find() interacts with the type system. Attempting to spread ...agentEntry?.heartbeat causes tsc to fail.

This PR adds a runtime check typeof agentEntry === "object" && agentEntry to ensure agentEntry is indeed an object before accessing the .heartbeat property, satisfying the TypeScript compiler and restoring CI to a passing state.

How was it tested?

  • pnpm exec tsc --noEmit passes locally without the TS2339 error.

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.
@openclaw-barnacle openclaw-barnacle bot added gateway Gateway runtime size: XS labels Feb 28, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 28, 2026

Greptile Summary

Fixed TypeScript compilation error (TS2339) in src/gateway/server-cron.ts by adding a type guard before accessing agentEntry.heartbeat.

  • The Array.isArray(...) && list.find(...) pattern on line 189 creates a union type false | AgentConfig | undefined
  • Accessing .heartbeat on this union caused TypeScript to fail since false doesn't have properties
  • Added runtime check typeof agentEntry === "object" && agentEntry to narrow the type before property access
  • Also includes minor indentation cleanup in resolveCronWakeTarget function

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The fix correctly resolves a TypeScript compilation error without changing runtime behavior. The type guard properly handles all cases in the union type (false/undefined/object), and the author verified the fix with pnpm exec tsc --noEmit. The change is minimal, well-tested locally, and follows TypeScript best practices.
  • No files require special attention

Last reviewed commit: 9ffc81a

Copy link

@nikolasdehor nikolasdehor left a comment

Choose a reason for hiding this comment

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

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.

@zakky8 zakky8 closed this Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants