Skip to content

fix(cli): CLI timeout fetching notices prints "unreachable" branch error message#20308

Merged
mergify[bot] merged 13 commits intoaws:mainfrom
Naumel:master
Jul 18, 2022
Merged

fix(cli): CLI timeout fetching notices prints "unreachable" branch error message#20308
mergify[bot] merged 13 commits intoaws:mainfrom
Naumel:master

Conversation

@Naumel
Copy link
Copy Markdown
Contributor

@Naumel Naumel commented May 12, 2022

fixes #20069

Problem: the error message should not be displayed. It was part of a backup timer acting as a fail-safe.

Additionally, the timer from setTimeout() is not cleared. the issue is being addressed by invoking unref().

Overall, the behavior is correct: the request is being terminated, but the error message prompted the users encountering it to open an issue.


All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented May 12, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team May 12, 2022 10:41
@github-actions github-actions bot added the p2 label May 12, 2022
return new Promise((resolve, reject) => {

var timer = setTimeout(() => {
reject(new Error('Request timed out.'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must call req.destroy, otherwise the socket will continue to do work in the background (causing node to not exit) even though we've stopped waiting for the result.

} catch (e) {
reject(new Error(`HTTPS 'get' call threw an error: ${e.message}`));
} finally {
clearTimeout(timer);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the finally will execute immediately after starting the async process, we'll immediately cancel the timer and the timeout will never fire. The unref by itself should do it.

Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two style nitpicks on the PR itself:

  • Our PR titles go into the CHANGELOG. Therefore, name them in a way that makes sense for people to read there. It will go under the heading "Bug fixes", so describe the bug that is fixed. For example: "CLI timeout fetching notices prints scary message"
  • Please use the PR body to describe what the bug was, what you did to fix it, and alternatives you considered but rejected (if applicable). Some extra context setting makes it easier to review, and because of our distributedness overcommunicating is usually better than undercommunicating.

@mergify mergify bot dismissed rix0rrr’s stale review May 13, 2022 09:09

Pull request has been modified.

@kaizencc
Copy link
Copy Markdown
Contributor

@Naumel If you change the PR description to say fixes #20308 my github action will pick up this link and label your PR with the correct priority of p1 rather than the current p2.

(That's how github suggests we link issues, but i guess it still picks up other ways too. Unfortunately, the github action I wrote is not as robust...)

@github-actions github-actions bot added bug This issue is a bug. p1 and removed p2 labels Jun 1, 2022
@Naumel Naumel changed the title fix(cli): unset timeout to avoid hanging fix(cli): CLI timeout fetching notices prints "unreachable" branch error message Jun 1, 2022
@TheRealAmazonKendra TheRealAmazonKendra changed the base branch from v1-main to main June 2, 2022 09:20
@Naumel
Copy link
Copy Markdown
Contributor Author

Naumel commented Jun 15, 2022

There is a test already checking for the timeout scenario, unless there's a suggestion for a more granular scenario I can write, I'll leave the existing tests as they are.

@Naumel Naumel marked this pull request as ready for review June 15, 2022 15:20
rix0rrr
rix0rrr previously approved these changes Jul 7, 2022
@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label Jul 7, 2022
@rix0rrr
Copy link
Copy Markdown
Contributor

rix0rrr commented Jul 7, 2022

Conditionally approved.

@mergify mergify bot dismissed rix0rrr’s stale review July 8, 2022 12:11

Pull request has been modified.

rix0rrr
rix0rrr previously approved these changes Jul 8, 2022
@mergify mergify bot dismissed rix0rrr’s stale review July 8, 2022 12:13

Pull request has been modified.

@Naumel Naumel removed the pr/do-not-merge This PR should not be merged at this time. label Jul 8, 2022
@kaizencc kaizencc added pr-linter/exempt-test The PR linter will not require test changes pr/do-not-merge This PR should not be merged at this time. labels Jul 11, 2022
@kaizencc
Copy link
Copy Markdown
Contributor

@Naumel I added the pr-linter/exempt-test label because I don't think you need to modify or add to the existing tests. However, I re-added pr/do-not-merge because the PR build does not automatically run CLI integ tests that will get run when the PR is merged to main. Can you run these integ tests locally, or on the test-pipeline to make sure that they will succeed? Then, I'm happy to remove the do-not-merge label.

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 12, 2022
@rix0rrr rix0rrr removed the pr/do-not-merge This PR should not be merged at this time. label Jul 18, 2022
@rix0rrr
Copy link
Copy Markdown
Contributor

rix0rrr commented Jul 18, 2022

I am confident and will deal with the consequences :)

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jul 18, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: ebb4879
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 7c4cd96 into aws:main Jul 18, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jul 18, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

comcalvi pushed a commit to comcalvi/aws-cdk that referenced this pull request Jul 25, 2022
…ror message (aws#20308)

fixes aws#20069

Problem: the [error message](https://github.com/aws/aws-cdk/blob/fd306ee05cfa7ebaa8d997007500d89d62868897/packages/aws-cdk/lib/notices.ts#L148-L154) should not be displayed. It was part of a backup timer acting as a fail-safe.

Additionally, the timer from `setTimeout()` is not cleared. the issue is being addressed by invoking `unref()`.

Overall, the behavior is correct: the request is being terminated, but the error message prompted the users encountering it to open an issue.



----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug This issue is a bug. contribution/core This is a PR that came from AWS. p1 pr-linter/exempt-test The PR linter will not require test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(cli): Notices timeout works but uses the second catch

4 participants