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

Improve watch mode #1542

Closed
3 tasks done
mrlubos opened this issue Jan 9, 2025 · 7 comments · Fixed by #1668
Closed
3 tasks done

Improve watch mode #1542

mrlubos opened this issue Jan 9, 2025 · 7 comments · Fixed by #1668
Assignees
Labels
feature 🚀 New feature or request prioritized 🚚 This issue has been prioritized and will be worked on soon

Comments

@mrlubos
Copy link
Member

mrlubos commented Jan 9, 2025

  • add timeout option to handle servers that stay down for tens of seconds while reloading
  • handle servers that do not expose HEAD method for spec
  • improve console message on reload (clear)
@mrlubos mrlubos added feature 🚀 New feature or request prioritized 🚚 This issue has been prioritized and will be worked on soon labels Jan 9, 2025
@mrlubos mrlubos self-assigned this Jan 9, 2025
@Matsuuu
Copy link
Contributor

Matsuuu commented Jan 27, 2025

This would be highly appriciated feature as I run this in watch mode while developing and having the CLI crash out constantly isn't quite the DX you want.

Just having the json parsing in a try-catch block could help to not crash the software

@mrlubos
Copy link
Member Author

mrlubos commented Feb 3, 2025

Hi @Matsuuu, please try the latest release v0.64.1 and let me know if it works as expected!

@Matsuuu
Copy link
Contributor

Matsuuu commented Feb 21, 2025

I am still getting crashes on the latest package version.

/node_modules/@hey-api/json-schema-ref-parser/dist/lib/resolvers/url.js:44

ResolverError: Error requesting http://localhost:5220/openapi/v1.json
fetch failed

I can try and make a minimal repro repository at some point if needed

@mrlubos
Copy link
Member Author

mrlubos commented Feb 21, 2025

@Matsuuu Are you able to find out why is it failing? What kind of request is it sending vs expected?

@Matsuuu
Copy link
Contributor

Matsuuu commented Feb 22, 2025

So I'm running a background service, which needs to be taken down, re-built and then started again, due to it not supporting a watch mode.

When I take the API down, the watch mode breaks as it's not able to query the endpoint.

Any setup I tried that supports actual watch modes worked flawlessly with this, but a compiled API that needs a "full restart" with a few seconds of downtime will break the watch mode.

The stacktrace points at /node_modules/@hey-api/json-schema-ref-parser/dist/lib/resolvers/url.js:44:15

I understand that the API being down should result in an warning / error but when using watch mode, I think a good dev experience would be that it just reports that "I'm not able to find anything at pointed url", instead of straight up throwing and error and stopping the whole process.

This can be easily simulated here by following the steps: Starting the api, starting the app, shutting down the api.

I would like that either by default, or via a flag these situations wouldn't crash the watcher.


I think there's 2 approaches to this.

  1. In watch mode, we report that the URL doesn't provide a output, with some info about it

  2. We only make it throw the error if it's the "Initial" run of a watch mode and not on concecutive ones.

I'd be happy to discuss further as I'm starting to adopt this tool in plenty of my projects and maybe even contributing if there's spots to contribute to.

@Matsuuu
Copy link
Contributor

Matsuuu commented Feb 26, 2025

Provided a small PR that fixes it. It ain't the most elegant thing but it does the job. I'd be happy to discuss if there's a better way #1748

@mrlubos
Copy link
Member Author

mrlubos commented Feb 26, 2025

Yep, will merge, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🚀 New feature or request prioritized 🚚 This issue has been prioritized and will be worked on soon
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants