Skip to content

Conversation

@iosephmagno
Copy link
Contributor

@iosephmagno iosephmagno commented Jun 14, 2025

This PR introduces a minor update to the initialize() method to avoid throwing when called multiple times. Instead, it logs an informational message and returns the existing instance, making initialization idempotent and smoother for production use.

  • Replaced assert(!_instance.isInitialized) with a runtime check to prevent throwing.
  • Added _log.info() when a reinitialization attempt occurs.
  • Exposed isInitialized as a public read-only getter for improved observability.
  • Avoids throwing errors in release mode by gracefully handling repeated initialization.

Closes #1163

This PR introduces a minor update to the initialize() method to avoid throwing when called multiple times. Instead, it logs an informational message and returns the existing instance, making initialization idempotent and smoother for production use.

- Replaced assert(!_instance.isInitialized) with a runtime check to prevent throwing.
- Added _log.info() when a reinitialization attempt occurs.
- Exposed isInitialized as a public read-only getter for improved observability.
- Avoids throwing errors in release mode by gracefully handling repeated initialization.
@dshukertjr dshukertjr changed the title [Supabase] Make initialize() idempotent feat(supabase_flutter): Make initialize() idempotent Jun 15, 2025
@dshukertjr dshukertjr changed the title feat(supabase_flutter): Make initialize() idempotent feat(supabase_flutter): Make initialize() idempotent Jun 15, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 15653250871

Details

  • 4 of 7 (57.14%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 80.634%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/supabase_flutter/lib/src/supabase.dart 4 7 57.14%
Totals Coverage Status
Change from base Build 15578916758: -0.06%
Covered Lines: 3102
Relevant Lines: 3847

💛 - Coveralls

@dshukertjr dshukertjr changed the title feat(supabase_flutter): Make initialize() idempotent feat(supabase_flutter): Make Supabase.initialize() idempotent Jun 15, 2025
@dshukertjr dshukertjr merged commit cc058e7 into supabase:main Jun 15, 2025
11 of 13 checks passed
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.

[feat request] Support isInitialized check to help use Supabase in background isolates

3 participants