From 12e0013f289f5f821beabdb2025bcc7fac5dc908 Mon Sep 17 00:00:00 2001 From: Chaim Marcus Date: Mon, 11 May 2026 12:26:25 +0000 Subject: [PATCH] fix(host): pass HttpClient to EspoCrmClient ctor + dispose on shutdown The composition root was calling EspoCrmClient(baseUrl, user, key, logger) which doesn't match the actual ctor signature EspoCrmClient(HttpClient, string, string, string, ILogger). One missing HttpClient argument = one compile error blocking the host build. - AddInHost now owns a single HttpClient (Timeout=30s), passed to EspoCrmClient on init, disposed alongside the retry processor and Serilog on shutdown. - baseUrl.ToString() satisfies the string parameter; the Uri.TryCreate upstream still validates the URL. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/OutlookAddin/Services/AddInHost.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OutlookAddin/Services/AddInHost.cs b/src/OutlookAddin/Services/AddInHost.cs index c95bf34..c70d5b9 100644 --- a/src/OutlookAddin/Services/AddInHost.cs +++ b/src/OutlookAddin/Services/AddInHost.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows; @@ -36,6 +37,7 @@ namespace OutlookAddin.Services private readonly Outlook.Application _outlookApp; private RetryQueueProcessor? _retryProcessor; + private HttpClient? _httpClient; public AddInHost(Outlook.Application outlookApp) { @@ -70,7 +72,8 @@ namespace OutlookAddin.Services try { - CrmClient = new EspoCrmClient(baseUrl, creds.Username, creds.ApiKey, Logger); + _httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(30) }; + CrmClient = new EspoCrmClient(_httpClient, baseUrl.ToString(), creds.Username, creds.ApiKey, Logger); FilingService = new FilingService(CrmClient, RetryQueue, Logger); _retryProcessor = new RetryQueueProcessor(RetryQueue, CrmClient, Logger); _retryProcessor.Start(); @@ -318,6 +321,7 @@ namespace OutlookAddin.Services public void Dispose() { try { _retryProcessor?.Dispose(); } catch { } + try { _httpClient?.Dispose(); } catch { } try { Logger.Information("AddInHost shutting down");