fix: resolve plugin initialization race condition (#75)#101
Merged
MarcosBrendonDePaula merged 1 commit intomainfrom Mar 14, 2026
Merged
fix: resolve plugin initialization race condition (#75)#101MarcosBrendonDePaula merged 1 commit intomainfrom
MarcosBrendonDePaula merged 1 commit intomainfrom
Conversation
Move `initializeAutomaticPlugins()` from fire-and-forget in the constructor to `await` inside `start()`, guaranteeing all auto-discovered plugins are fully loaded before the server accepts traffic. Add 10 unit tests covering lifecycle hook ordering, dependency validation after discovery, onConfigLoad execution, and error resilience. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
initializeAutomaticPlugins()from fire-and-forget in the constructor toawaitinsidestart(), ensuring all auto-discovered plugins are fully initialized before the server accepts traffic.onConfigLoadexecution, and error resilience.Closes #75
What was the problem?
If
listen()was called before plugin discovery finished, auto-discovered plugins would misssetup(),onBeforeServerStart(),onServerStart(), andonAfterServerStart()hooks.What changed?
core/framework/server.ts: Removed fire-and-forget from constructor; addedawait this.initializeAutomaticPlugins()at the top ofstart()tests/unit/core/plugin-init-race-condition.test.ts: 10 new testsTest plan
bun run devstarts without regressions🤖 Generated with Claude Code