Skip to content

Conversation

Copy link

Copilot AI commented Nov 13, 2025

The ConfigInvalidation.setup() function used a module-level boolean flag to prevent duplicate subscriptions, creating a race condition when called concurrently—multiple calls could pass the check before any set the flag.

Changes:

  • Replace initialized boolean with setupPromise: Promise<void> | undefined
  • Make setup() async, returning the stored Promise on subsequent calls
  • Await ConfigInvalidation.setup() in InstanceBootstrap()

Before:

let initialized = false
export function setup() {
  if (initialized) return
  initialized = true
  Bus.subscribe(Config.Event.Updated, async (event) => { ... })
}

After:

let setupPromise: Promise<void> | undefined
export async function setup() {
  if (setupPromise) return setupPromise
  setupPromise = (async () => {
    Bus.subscribe(Config.Event.Updated, async (event) => { ... })
  })()
  return setupPromise
}

Concurrent calls now await the same initialization Promise, ensuring exactly-once setup.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…pattern

Co-authored-by: kcrommett <523952+kcrommett@users.noreply.github.com>
Copilot AI changed the title [WIP] Add changes to address feedback on merge config reload Fix race condition in ConfigInvalidation.setup() with Promise-based init Nov 13, 2025
Copilot AI requested a review from shuv1337 November 13, 2025 05:55
Copy link
Collaborator

@shuv1337 shuv1337 left a comment

Choose a reason for hiding this comment

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

@codex review this

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@shuv1337 shuv1337 marked this pull request as ready for review November 13, 2025 06:01
@shuv1337 shuv1337 merged commit c25e592 into merge-config-reload Nov 13, 2025
2 of 4 checks passed
@shuv1337 shuv1337 deleted the copilot/sub-pr-12 branch November 21, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants