Skip to content

Fix Temporal worker startup order#319

Merged
hughneale merged 3 commits into
mainfrom
fix/temporal-register-before-start
Apr 27, 2026
Merged

Fix Temporal worker startup order#319
hughneale merged 3 commits into
mainfrom
fix/temporal-register-before-start

Conversation

@hughneale
Copy link
Copy Markdown
Contributor

Summary

Briefly describe what this PR does and why. Link to the relevant issue or context.

Closes #


Type of Change

  • feat – New feature (minor version bump)
  • fix – Bug fix (patch version bump)
  • refactor – Code refactoring, no functional change
  • docs – Documentation only
  • test – Adding or updating tests
  • chore – Build, CI, dependency updates
  • major / BREAKING CHANGE – Breaking change (major version bump)

What Changed

A concise list of the changes made. Focus on the what and why, not the how.


Provider / Workflow / Role Changes

Complete this section if you've added or modified providers, workflows, or roles. Delete if not applicable.

Area Change Notes
Provider
Workflow
Role
  • Provider config files updated (config/providers/)
  • Role config files updated (config/roles/)
  • Workflow definitions updated (config/workflows/)
  • Example configs updated (examples/)

Security Considerations

This project handles privileged access. Describe any security implications of this change.

  • No security impact
  • Reviewed for least-privilege impact
  • Access grant / revocation logic reviewed
  • Audit trail is preserved for any new access paths
  • No credentials, tokens, or secrets introduced in code or config

Security notes (if applicable):


Testing

Describe how this was tested. Include commands if helpful.

  • Unit tests pass (go test ./...)
  • Functional tests pass
  • Integration tests pass
  • Manually tested locally — describe scenario below

Manual test scenario (if applicable):

# Describe the steps taken to verify the change works end-to-end

Breaking Changes

If this is a breaking change, describe the impact and any migration steps required.

  • This PR does not introduce breaking changes
  • This PR does introduce breaking changes (describe below)

Migration steps (if applicable):


Documentation

  • No documentation changes needed
  • In-code comments updated
  • docs/ updated
  • README.md updated
  • Config examples updated

Checklist

  • My branch is up to date with main
  • Commit messages follow the conventional commit format (feat:, fix:, major:, etc.)
  • No debug code, hardcoded values, or temporary workarounds left in
  • All new code has appropriate test coverage
  • I have reviewed my own diff before requesting review

Copilot AI review requested due to automatic review settings April 25, 2026 20:39
@hughneale hughneale added the fix Bug fix (patch version bump) label Apr 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts Temporal initialization so workflows/activities are registered before any Temporal workers are started, preventing startup-order issues.

Changes:

  • Added an explicit StartWorkers() lifecycle step to the Temporal service interface and implementation.
  • Moved Temporal worker startup to occur after workflow/activity registration (and after provider initialization in server mode).
  • Updated Temporal integration test setup to start workers after registration.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/integration/services/temporal_test.go Starts Temporal workers after registering test workflow/activity.
internal/models/temporal.go Extends Temporal service interface with StartWorkers().
internal/config/temporal.go Uses servicesClient directly when registering Temporal workflows/activities.
internal/config/services/temporal/multi_worker.go Updates lifecycle comment to reflect new StartWorkers() step.
internal/config/services/temporal/main.go Splits worker creation vs startup; adds worker-start tracking/state.
internal/config/services.go Makes Temporal setup run during service initialization; adds StartTemporalWorkers().
internal/config/providers.go Ensures services are initialized earlier (server mode) and starts Temporal workers after providers init.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/config/services.go Outdated
Comment thread internal/config/providers.go
Comment thread internal/config/services/temporal/main.go
…ync.Once race

- TemporalClient.started map was only ever written and len()-checked in
  StartWorkers(), then nilled in Shutdown(). Replace with a local
  startedCount variable — workers remains the single authoritative map.

- SetupTemporal() was called inside GetServices()'s sync.Once, which
  meant any early non-server caller (e.g. HasAnalytics() from the
  config.Load() goroutine) would consume the Once and leave Temporal
  workflows/activities permanently unregistered for the process.

  Move SetupTemporal() out of the sync.Once and into InitializeProviders(),
  which is only invoked from explicit server-start paths after
  SetMode(ModeServer) has already run. Return the error instead of just
  logging it — a registration failure is fatal for a server process.
@hughneale hughneale merged commit 531a36e into main Apr 27, 2026
13 checks passed
@hughneale hughneale deleted the fix/temporal-register-before-start branch April 27, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix (patch version bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants