From 34fdc778183cc63e518ef71e7dce6e2b7122cd18 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sun, 4 Jan 2026 20:08:46 +0100 Subject: [PATCH] fix: prevent API client provider auto-dispose causing Ref invalidation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit API client providers (coreApiClientProvider, tatlockApiClientProvider) now use keepAlive: true. This fixes "DioException [unknown]: null" errors on pages like /security/users where ref.read() was used without subscription. The AuthInterceptor stores a Ref that became invalid when the provider auto-disposed after a one-time read. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- CHANGELOG.md | 7 +++++++ lib/core/api/api_client.dart | 10 ++++++++-- pubspec.yaml | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0a86bf..7a7ec97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.11] - 2026-01-04 + +### Fixed +- API client providers now use `keepAlive: true` to prevent Ref invalidation + - Fixes "DioException [unknown]: null" error on /security/users and other API pages + - AuthInterceptor's stored Ref was becoming invalid when provider auto-disposed + ## [1.1.10] - 2026-01-04 ### Changed diff --git a/lib/core/api/api_client.dart b/lib/core/api/api_client.dart index 6ee647f..1c76837 100644 --- a/lib/core/api/api_client.dart +++ b/lib/core/api/api_client.dart @@ -9,7 +9,10 @@ import 'api_client_native.dart' if (dart.library.html) 'api_client_web.dart' part 'api_client.g.dart'; /// Provides the Dio instance for Core API. -@riverpod +/// +/// Uses keepAlive to prevent auto-dispose - the AuthInterceptor stores +/// a Ref that must remain valid for the lifetime of API requests. +@Riverpod(keepAlive: true) Dio coreApiClient(Ref ref) { final options = BaseOptions( baseUrl: AppConfig.coreApiUrl, @@ -33,7 +36,10 @@ Dio coreApiClient(Ref ref) { } /// Provides the Dio instance for Tatlock API. -@riverpod +/// +/// Uses keepAlive to prevent auto-dispose - the AuthInterceptor stores +/// a Ref that must remain valid for the lifetime of API requests. +@Riverpod(keepAlive: true) Dio tatlockApiClient(Ref ref) { final options = BaseOptions( baseUrl: AppConfig.tatlockApiUrl, diff --git a/pubspec.yaml b/pubspec.yaml index 8b414a0..13b19a7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.1.10+1 +version: 1.1.11+1 environment: sdk: ^3.10.4