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

Watch mode throws error when local server reloads #1534

Open
nhruch opened this issue Jan 7, 2025 · 4 comments
Open

Watch mode throws error when local server reloads #1534

nhruch opened this issue Jan 7, 2025 · 4 comments
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon

Comments

@nhruch
Copy link

nhruch commented Jan 7, 2025

Description

When running in watch mode with an endpoint that is local, openapi-ts will exit with an error if the openapi endpoint serving the specification temporarily goes down. This is a ResolverError and occurs when calling sendRequest in @hey-api/json-schema-ref-parser/lib/resolvers/url.ts.

I am working in a monorepo and the endpoint in http://localhost:3001/api/swagger-json which is served by NestJS. When reloading, the server will temporarily stop running the HTTP server and the request fails to connect resulting in an error that is caught by the try/catch block.

I'm not sure what the correct solution would be here. Does this need to be run with an NGINX proxy in front of the server or could we add an option to ignore failure to connect until the server comes back online?

I'm unable to grab the problematic code as its in a client's isolated network.

Reproducible example or configuration

https://stackblitz.com/edit/hey-api-client-fetch-example

OpenAPI specification (optional)

No response

System information (optional)

Using a PNPM monorepo in an Kubernetes Alpine container.

@nhruch nhruch added the bug 🔥 Something isn't working label Jan 7, 2025
Copy link

stackblitz bot commented Jan 7, 2025

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@mrlubos
Copy link
Member

mrlubos commented Jan 8, 2025

Hi @nhruch, do you know how long it usually takes for the server to come back up? Or at least in this case where it fails

@nhruch
Copy link
Author

nhruch commented Jan 8, 2025

The server takes about 15 seconds to reload but it seems like openapi-ts errors on the 1 second interval check of the e-tag.

@mrlubos
Copy link
Member

mrlubos commented Jan 8, 2025

Got it. Looks like I should add a timeout option and throw only when that's expired. Thanks for reporting!

@mrlubos mrlubos added the prioritized 🚚 This issue has been prioritized and will be worked on soon label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working prioritized 🚚 This issue has been prioritized and will be worked on soon
Projects
None yet
Development

No branches or pull requests

2 participants