_syncHostJobs runs on facet instances even though the root owns the alarm

Open Beginner friendly
#2,299 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Start at Agent._syncHostJobs() and compare its facet behavior with rootAlarmOwner(), which delegates alarm scheduling to the root. Verify that facet instances skip host-job synchronization while root instances retain it, and confirm that facet wakes no longer create schedule_agent_alarm spans; the root should still synchronize its host jobs.

Written by the indexing model from the issue text.

Description

Summary

Agent._syncHostJobs() runs on facet instances as well as on the root. A facet cannot own the alarm (its scheduling is delegated to rootAlarmOwner()), so every facet wake still opens a schedule_agent_alarm span and synchronises host jobs that the root already owns. On a parent with several long-lived facets this is wasted storage and span volume on every wake, and it makes the facet's trace look like an alarm owner.

Seen on agents@0.23.0.

Suggestion

Return early from _syncHostJobs() when this._isFacet is set. We carry exactly that one-line guard as a local patch and have not seen a facet-side job that needed the sync; if there is one, a facet-specific path would be clearer than running the root's synchronisation on every facet.

Dominant language
TypeScript
Stars
5.6k
Forks
726
Avg merge
1d 17h
Merged PRs (30d)
49

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cloudflare/agents

All issues in cloudflare/agents

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.