Skip to content

Conversation

@nkomonen-amazon
Copy link
Contributor

@nkomonen-amazon nkomonen-amazon commented Apr 24, 2025

Problem:

When the server restarted due to a crash, the auth token was not sent again. This caused users to run in to the state where if it crashed and restarted, when they sent a subsequent chat message they'd get stuck with the server asking the user to Authenticate.

Note that server restart is triggered automatically by the LanguageClient, I think.

Solution:

Detect when the server is restarted and manually resend the bearer token again.

Note, this solution needs to be revisited since there may be other initialization logic that needs to run on server restart, aside from just the bearer token.

Repro Steps:

  1. Ensure you do not have a workspace open, you can open a new vscode window at the top left File > New Window
  2. Make a random folder in your home directory
  3. Make a couple typescript files in that folder
  4. Send the prompt: list all files in {folder}
  5. Accept the permissions
  6. Click the toggle drop down from the response, and click the link to the path (this is just to force a crash + restart)
  7. Verify the server crashed in the logs, look for the message Connection to server got closed. Server will restart.
  8. ASSUMING this fix worked, the server will restart automatically and you can continue using chat. Before this fix any subsequent messages would ask the user to Authenticate again

  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

Problem:

When the server restarted due to a crash, the auth token was not
sent again.

Note that server restart is triggered automatically by the LanguageClient, I think.

Solution:

Detect when the server is restarted and manually resend the bearer token again.

Note, this solution needs to be revisited since there may be other initialization logic
that needs to run on server restart, aside from just the bearer token.

Signed-off-by: nkomonen-amazon <[email protected]>
@nkomonen-amazon nkomonen-amazon requested a review from a team as a code owner April 24, 2025 15:58
@github-actions
Copy link

  • This pull request modifies code in src/* but no tests were added/updated.
    • Confirm whether tests should be added or ensure the PR description explains why tests are not required.
  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

@nkomonen-amazon
Copy link
Contributor Author

/retryBuilds

@nkomonen-amazon nkomonen-amazon merged commit d2f6b9a into aws:feature/hybridChat Apr 24, 2025
33 of 37 checks passed
@nkomonen-amazon nkomonen-amazon deleted the serverRestartAuthFix branch April 24, 2025 16:35
opieter-aws pushed a commit to opieter-aws/aws-toolkit-vscode that referenced this pull request Apr 24, 2025
## Problem:

When the server restarted due to a crash, the auth token was not sent
again. This caused users to run in to the state where if it crashed and
restarted, when they sent a subsequent chat message they'd get stuck
with the server asking the user to Authenticate.

Note that server restart is triggered automatically by the
LanguageClient, I think.

## Solution:

Detect when the server is restarted and manually resend the bearer token
again.

Note, this solution needs to be revisited since there may be other
initialization logic that needs to run on server restart, aside from
just the bearer token.

## Repro Steps:

1. Ensure you do not have a workspace open, you can open a new vscode
window at the top left `File` > `New Window`
2. Make a random folder in your home directory
3. Make a couple typescript files in that folder
4. Send the prompt: `list all files in {folder}`
5. Accept the permissions
6. Click the toggle drop down from the response, and click the link to
the path (this is just to force a crash + restart)
7. Verify the server crashed in the logs, look for the message
`Connection to server got closed. Server will restart.`
8. ASSUMING this fix worked, the server will restart automatically and
you can continue using chat. Before this fix any subsequent messages
would ask the user to `Authenticate` again

---

- Treat all work as PUBLIC. Private `feature/x` branches will not be
squash-merged at release time.
- Your code changes must meet the guidelines in
[CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines).
- License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.

Signed-off-by: nkomonen-amazon <[email protected]>
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.

3 participants