Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redocly/cli lint hangs for a while before exiting #1146

Closed
philipnbbc opened this issue Jun 28, 2023 · 21 comments · Fixed by #1151, #1169, #1433, #1461 or #1493
Closed

redocly/cli lint hangs for a while before exiting #1146

philipnbbc opened this issue Jun 28, 2023 · 21 comments · Fixed by #1151, #1169, #1433, #1461 or #1493
Labels
p3 Type: Bug Something isn't working

Comments

@philipnbbc
Copy link

Describe the bug

Running version >= v1.0.0-beta.127 (latest is v1.0.0-beta.129) of redocly/cli Docker results in the validation completing and then the process sits there for a while before exiting. The wait time can be significant (30 sec) for larger OpenAPI spec files.

To Reproduce
Steps to reproduce the behavior:

A small OpenAPI file, example.yaml:

openapi: 3.0.3
info:
  title: Test
paths:
  /:
    get:
      responses:
        '200':
  1. Given the OpenAPI example file shown above
  2. Run docker run --rm -v $PWD:/spec redocly/cli lint example.yaml
  3. It outputs "run redocly lint --generate-ignore-file to add all problems to the ignore file." and then sits there for a couple seconds
  4. Run docker run --rm -v $PWD:/spec redocly/cli:v1.0.0-beta.126 lint example.yaml and it exits immediately

Using a larger OpenAPI file results in a longer and more significant hang time.

Expected behavior

It shouldn't, or it is unclear why it would hang for a while before exiting.

Redocly Version(s)

Issue is with Docker image redocly/cli version >= v1.0.0-beta.127 (latest == v1.0.0-beta.129)

@philipnbbc philipnbbc added the Type: Bug Something isn't working label Jun 28, 2023
@philipnbbc
Copy link
Author

philipnbbc commented Jun 29, 2023

Tried something... It turns out it hangs when behind a proxy. I assume it is attempting to make a HTTP request?

Can that behavior be disabled? Switching telemetry off doesn't make a difference: docker run --rm -e REDOCLY_TELEMETRY=off -v $PWD:/spec redocly/cli lint example.yaml

@lornajane
Copy link
Contributor

Thanks for the update, although you've disproved my working hypothesis which was that the telemetry could cause a problem despite our testing on it! We'll take a look and keep you posted.

@tatomyr
Copy link
Contributor

tatomyr commented Jul 3, 2023

Hi @philipnbbc,
Could you check if setting env variable CI=true solves this?

@philipnbbc
Copy link
Author

Could you check if setting env variable CI=true solves this?

I ran docker run --rm -e CI=true -v $PWD:/spec redocly/cli lint example.yaml and the issue remains.

The output of tcpdump showed DNS queries for api.redocly.com.

@tatomyr
Copy link
Contributor

tatomyr commented Jul 3, 2023

Which version is this? Could you also switch off the telemetry? My last guess is this is a combo 😅

@philipnbbc
Copy link
Author

🎉 That did the trick. It returns immediately and tcpdump no longer shows api.redocly.com. This was the latest / v1.0.0-beta.129 version.

@yuan1238y
Copy link

I tried set the environment REDOCLY_TELEMETRY=off resolve this problem.
This version is v1.0.0-beta.129

@tatomyr tatomyr added the p2 label Jul 3, 2023
@philipnbbc
Copy link
Author

I tried set the environment REDOCLY_TELEMETRY=off resolve this problem.
This version is v1.0.0-beta.129

I double-checked what works for me.

  • -e REDOCLY_TELEMETRY=off: results in a delay and tcpdump shows lookups for registry.npmjs.org
  • -e CI=true: results in a delay and tcpdump shows lookups for api.redocly.com
  • -e REDOCLY_TELEMETRY=off -e CI=true: results in no delay and tcpdump show no lookups

@tatomyr
Copy link
Contributor

tatomyr commented Jul 6, 2023

@philipnbbc, @yuan1238y,

Could you check whether the issue has been resolved in version 1.0.0-beta.130? Now it should exit correctly without additional env variables.

@philipnbbc
Copy link
Author

It hasn't fixed it for me unfortunately. I ran docker run --rm -v $PWD:/spec redocly/cli:v1.0.0-beta.130 lint example.yaml and it can hang a couple seconds or a lot more.

I also tried it with -e REDOCLY_TELEMETRY=off or -e CI=true (not both) and they both hang. It wasn't clear whether one or the other had improved.

@tatomyr
Copy link
Contributor

tatomyr commented Jul 7, 2023

Thanks @philipnbbc.

Reopening the issue.

@tatomyr
Copy link
Contributor

tatomyr commented Jul 10, 2023

@philipnbbc Hi, could you check it one more time with beta.131?

@philipnbbc
Copy link
Author

I ran docker run --rm -v $PWD:/spec redocly/cli:v1.0.0-beta.131 lint example.yaml and it has the same issue.

I confirmed that without docker that @redocly/[email protected] fixed the delay issue.

I don't see the proxy in the tcpdump output and so I guess the fundamental issue is that there is nodejs code trying to connect that doesn't support proxies and recognise the proxy environment variables.

@tatomyr
Copy link
Contributor

tatomyr commented Jul 11, 2023

Thanks @philipnbbc,

We will continue researching this then.

@tatomyr tatomyr reopened this Jul 11, 2023
@tatomyr
Copy link
Contributor

tatomyr commented Jul 11, 2023

I'm trying to replicate this by calling a very slow endpoint, and I cannot see it hanging for too long. How long is the delay for you? Has it been changed in the recent updates? Any additional reproduction steps or info you can provide us with (e.g. OS, nodeJS version &c.)?

@philipnbbc
Copy link
Author

I think the issue is that we have a proxy and network traffic has to go via that proxy. It appears from the tcpdump that the code is attempting to make connections without going via the proxy. I checked that the proxy environment variables are set in the docker container.

The tcpdump shows DNS queries for registry.npmjs.org which returns 12 IP addresses. There is then many rounds of attempts made to connect to those addresses. If I add -e CI=true it does the same but for api.redocly.com and it attempts to connect to the 3 AWS IP addresses.

I ran the cli docker a couple times and it was taking around 2 min 12 sec fairly consistently. It does vary because the delay was less last week.

I've had issues with other nodejs code that don't support proxies, but in this case we can workaround it by using the 2 environment variables.

@tatomyr tatomyr added Type: Bug Something isn't working and removed Type: Bug Something isn't working p2 labels Jul 17, 2023
@tatomyr
Copy link
Contributor

tatomyr commented Jul 17, 2023

I am putting it on hold for now, as there is a workaround.

@tatomyr tatomyr removed their assignment Feb 7, 2024
@tatomyr
Copy link
Contributor

tatomyr commented Feb 7, 2024

Note: this is tangentially related.

@tatomyr
Copy link
Contributor

tatomyr commented Jul 31, 2024

JFYI @philipnbbc, hopefully this should have been fixed in v1.16.0. 😅

@philipnbbc
Copy link
Author

JFYI @philipnbbc, hopefully this should have been fixed in v1.16.0. 😅

Yes it has, thank you 🎉

@tatomyr
Copy link
Contributor

tatomyr commented Jan 22, 2025

@philipnbbc we're going to remove the node-fetch dependency, which may impact how Redocly CLI works behind proxies (here's the corresponding PR). There's a test version with these changes (0.0.0-snapshot.1737556585) which you can try and check if it breaks anything for you.

cc @DmitryAnansky @yuan1238y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment