aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
764 stars 220 forks source link

Offline Failures Cause Significant Keystroke Lag #4868

Closed jamesward closed 1 month ago

jamesward commented 2 months ago

Describe the bug

When I'm offline, keystrokes get very laggy in the IntelliJ editor. Looking at the logs it appears that Q Dev is failing to connect to something on each keystroke:

2024-09-06 00:36:42,509 [  70252]   WARN - software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService - prompt reauth failed with unexpected error
software.amazon.awssdk.core.exception.SdkClientException: Received an UnknownHostException when attempting to interact with a service. See cause for the exact endpoint that is failing to resolve. If this is happening on an endpoint that previously worked, there may be a network connectivity issue or your DNS cache could be storing endpoints for too long.
    at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:111)
    at software.amazon.awssdk.awscore.interceptor.HelpfulUnknownHostExceptionInterceptor.modifyException(HelpfulUnknownHostExceptionInterceptor.java:59)
    at software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain.modifyException(ExecutionInterceptorChain.java:181)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.utils.ExceptionReportingUtils.runModifyException(ExceptionReportingUtils.java:54)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.utils.ExceptionReportingUtils.reportFailureToInterceptors(ExceptionReportingUtils.java:38)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:39)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:26)
    at software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:210)
    at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:103)
    at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.doExecute(BaseSyncClientHandler.java:173)
    at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.lambda$execute$1(BaseSyncClientHandler.java:80)
    at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.measureApiCallSuccess(BaseSyncClientHandler.java:182)
    at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:74)
    at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:45)
    at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53)
    at software.amazon.awssdk.services.ssooidc.DefaultSsoOidcClient.createToken(DefaultSsoOidcClient.java:171)
    at software.amazon.awssdk.services.ssooidc.SsoOidcClient.createToken(SsoOidcClient.java:232)
    at software.aws.toolkits.jetbrains.core.credentials.sso.SsoAccessTokenProvider.refreshToken(SsoAccessTokenProvider.kt:392)
    at software.aws.toolkits.jetbrains.core.credentials.sso.bearer.InteractiveBearerTokenProvider.refresh(BearerTokenProvider.kt:169)
    at software.aws.toolkits.jetbrains.core.credentials.sso.bearer.InteractiveBearerTokenProvider.refreshToken(BearerTokenProvider.kt:142)
    at software.aws.toolkits.jetbrains.core.credentials.sso.bearer.InteractiveBearerTokenProvider.supplier$lambda$0(BearerTokenProvider.kt:109)
    at software.amazon.awssdk.utils.cache.CachedSupplier.lambda$jitteredPrefetchValueSupplier$8(CachedSupplier.java:300)
    at software.amazon.awssdk.utils.cache.NonBlocking.fetch(NonBlocking.java:151)
    at software.amazon.awssdk.utils.cache.CachedSupplier.refreshCache(CachedSupplier.java:208)
    at software.amazon.awssdk.utils.cache.CachedSupplier.get(CachedSupplier.java:135)
    at software.aws.toolkits.jetbrains.core.credentials.sso.bearer.InteractiveBearerTokenProvider.resolveToken(BearerTokenProvider.kt:151)
    at software.aws.toolkits.jetbrains.core.credentials.ToolkitAuthManagerKt$maybeReauthProviderIfNeeded$2.invoke(ToolkitAuthManager.kt:297)
    at software.aws.toolkits.jetbrains.core.credentials.ToolkitAuthManagerKt$maybeReauthProviderIfNeeded$2.invoke(ToolkitAuthManager.kt:296)
    at software.aws.toolkits.jetbrains.utils.ThreadingUtilsKt.runUnderProgressIfNeeded(ThreadingUtils.kt:32)
    at software.aws.toolkits.jetbrains.core.credentials.ToolkitAuthManagerKt.maybeReauthProviderIfNeeded(ToolkitAuthManager.kt:296)
    at software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.promptReAuth(CodeWhispererUtil.kt:191)
    at software.aws.toolkits.jetbrains.services.codewhisperer.util.CodeWhispererUtil.promptReAuth$default(CodeWhispererUtil.kt:187)
    at software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService$showRecommendationsInPopup$shouldReauth$1.invoke(CodeWhispererService.kt:121)
    at software.aws.toolkits.jetbrains.services.codewhisperer.service.CodeWhispererService$showRecommendationsInPopup$shouldReauth$1.invoke(CodeWhispererService.kt:120)
    at software.aws.toolkits.jetbrains.utils.ThreadingUtilsKt.pluginAwareExecuteOnPooledThread$lambda$3(ThreadingUtils.kt:86)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport$executeOnPooledThread$2.call(AnyThreadWriteThreadingSupport.kt:162)
    at com.intellij.util.concurrency.ContextCallable.call(ContextCallable.java:32)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
    at com.intellij.util.concurrency.ContextRunnable.run(ContextRunnable.java:27)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:735)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:732)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:732)
    at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: software.amazon.awssdk.core.exception.SdkClientException: Unable to execute HTTP request: oidc.us-east-1.amazonaws.com
    at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:111)
    at software.amazon.awssdk.core.exception.SdkClientException.create(SdkClientException.java:47)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.utils.RetryableStageHelper2.setLastException(RetryableStageHelper2.java:226)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage2.execute(RetryableStage2.java:65)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage2.execute(RetryableStage2.java:36)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:53)
    at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:35)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.executeWithTimer(ApiCallTimeoutTrackingStage.java:80)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:60)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:42)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallMetricCollectionStage.execute(ApiCallMetricCollectionStage.java:50)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallMetricCollectionStage.execute(ApiCallMetricCollectionStage.java:32)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37)
    ... 40 more
    Suppressed: software.amazon.awssdk.core.exception.SdkClientException: Request attempt 1 failure: Unable to execute HTTP request: oidc.us-east-1.amazonaws.com
    Suppressed: software.amazon.awssdk.core.exception.SdkClientException: Request attempt 2 failure: Unable to execute HTTP request: oidc.us-east-1.amazonaws.com
    Suppressed: software.amazon.awssdk.core.exception.SdkClientException: Request attempt 3 failure: Unable to execute HTTP request: oidc.us-east-1.amazonaws.com
Caused by: java.net.UnknownHostException: oidc.us-east-1.amazonaws.com
    at java.base/java.net.InetAddress$CachedLookup.get(InetAddress.java:988)
    at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1818)
    at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1688)
    at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:112)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
    at software.amazon.awssdk.http.apache.internal.conn.ClientConnectionManagerFactory$DelegatingHttpClientConnectionManager.connect(ClientConnectionManagerFactory.java:86)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
    at software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72)
    at software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:254)
    at software.amazon.awssdk.http.apache.ApacheHttpClient.access$500(ApacheHttpClient.java:104)
    at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:231)
    at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:228)
    at software.amazon.awssdk.core.internal.util.MetricUtils.measureDurationUnsafe(MetricUtils.java:99)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:79)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:57)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:40)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:72)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:42)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:78)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:40)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptMetricCollectionStage.execute(ApiCallAttemptMetricCollectionStage.java:55)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptMetricCollectionStage.execute(ApiCallAttemptMetricCollectionStage.java:39)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage2.executeRequest(RetryableStage2.java:93)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage2.execute(RetryableStage2.java:56)
    ... 52 more

To reproduce

  1. Go offline
  2. Try to write some code

Expected behavior No keystroke lag when offline

Your Environment Amazon Q Plugin Version = 3.27-242 IntelliJ Version = 2024.2.1

byowens commented 1 month ago

I came to the issue queue to write about the same problem. I have been using Amazon Q daily since ~January 2024 and this has always been a problem. I have yet to come and post this because re-authenticating fixes it so it has not bothered me enough to spend the time to come to the issue queue. But after 9 months and still not happening I came here to find out if it was reported yet or not.

I am using AWS SSO/Control Tower which has an expiration of 8 hours, so I get this problem a lot.

The steps to reproduce are exactly as @jamesward has said.

Worth noting this affects every plugin for all Jetbrains products.

rli commented 1 month ago

Fixed in 3.29