Skip to content

Commit

Permalink
AutoServiceScopes strikes again (#3072)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misha-133 authored Mar 1, 2025
1 parent 6fb2a29 commit d71fcb1
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ protected virtual string GetLogString(IInteractionContext context)
public Task<IResult> ExecuteAsync(IInteractionContext context, IAutocompleteInteraction autocompleteInteraction, IParameterInfo parameter,
IServiceProvider services)
{
using IServiceScope scope = InteractionService._autoServiceScopes ? services?.CreateScope() : null;
services = InteractionService._autoServiceScopes ? scope?.ServiceProvider ?? EmptyServiceProvider.Instance : services;

switch (InteractionService._runMode)
{
case RunMode.Sync:
Expand All @@ -57,6 +54,14 @@ private async Task<IResult> ExecuteInternalAsync(IInteractionContext context, IA
{
try
{
await using var scope = InteractionService._autoServiceScopes
? services?.CreateAsyncScope()
: null;

services = (InteractionService._autoServiceScopes
? scope?.ServiceProvider
: services) ?? EmptyServiceProvider.Instance;

var result = await GenerateSuggestionsAsync(context, autocompleteInteraction, parameter, services).ConfigureAwait(false);

if (result.IsSuccess)
Expand Down

0 comments on commit d71fcb1

Please sign in to comment.