Skip to content

fix(bootstrap): ensure bootstrap runs only once for concurrent requests#833

Draft
furelid wants to merge 1 commit into
SonicJs-Org:mainfrom
furelid:fix/bootstrap-in-path
Draft

fix(bootstrap): ensure bootstrap runs only once for concurrent requests#833
furelid wants to merge 1 commit into
SonicJs-Org:mainfrom
furelid:fix/bootstrap-in-path

Conversation

@furelid
Copy link
Copy Markdown
Contributor

@furelid furelid commented May 16, 2026

Description

This pull request improves the reliability of the bootstrap process in the middleware by ensuring that system initialization is only executed once, even under concurrent cold-start requests. It introduces a mechanism to prevent duplicate bootstrap runs, adds a comprehensive test for concurrency, and updates the reset logic to support repeated testing.

These changes make the bootstrap process more robust and the tests more reliable.

Fixes: not applicable, improvementqq 1

Changes

Concurrency handling and bootstrap logic:

  • Added a bootstrapInFlight promise to the bootstrap middleware in bootstrap.ts to ensure that concurrent requests during cold start will wait for the same initialization process, preventing multiple bootstrap executions. Q[1] [2] [3]
  • Updated the resetBootstrap function to clear both bootstrapComplete and bootstrapInFlight, ensuring tests and future requests start with a clean state.

Testing

  • Added a new test in bootstrap.test.ts to verify that concurrent cold-start requests only trigger a single bootstrap run, and that all dependent services are only called once.
  • Ensured all mocks are cleared and bootstrap state is reset before each test in the resetBootstrap test suite for better isolation.
  • Added missing mock for the syncAllFormCollections service and imported it for use in assertions. [1] [2]

Unit Tests

  • Added/updated unit tests
  • All unit tests passing

E2E Tests

  • Added/updated E2E tests
  • All E2E tests passing

Screenshots/Videos

Checklist

  • Code follows project conventions
  • Tests added/updated and passing
  • Type checking passes
  • No console errors or warnings
  • Documentation updated (if needed)

Generated with Claude Code in Conductor

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.

1 participant