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

fastify.swagger() silently crashes, with no output #824

Open
2 tasks done
RyanIgo opened this issue Sep 26, 2024 · 1 comment
Open
2 tasks done

fastify.swagger() silently crashes, with no output #824

RyanIgo opened this issue Sep 26, 2024 · 1 comment

Comments

@RyanIgo
Copy link

RyanIgo commented Sep 26, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.26.2

Plugin version

8.14.0

Node.js version

18.x

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

WSL

Description

``On occasion in my app, I have been running into an issue where running fastify.swagger() silently crashes and has no output. I have encountered this issue a few times over the past month. My initial resolution to this was to break swagger doc gen up to only include selective routes by (admin or feature) and limiting the number of routes to a couple hundred was working.

I am currently encountering this issue in a route with about 50 routes, I have a few features with approximately 200 routes being handled.

What are the recommended ways to inspect what is causing the problem with-in the library? Any ideas on what may be causing fastify.swagger() to fail?

When this issue occurs, the last log console.log I see when the error occurs is "starting fastify", My error statement is never reached?

 ```typescript

try {
//Save Swagger Docs
await makeDir("./doc");
console.log("starting fastify");
await fastify.ready();

console.log("starting swagger"); //LAST ITEM on log when error occurs
const swagger = fastify.swagger();
let group =
  process.argv.find((a) => a.includes("group"))?.split("=")[1] ||
  "undefined";
console.log(`starting writiting file ${group}`);
await writeFile(`./doc/${group}.json`, JSON.stringify(swagger));
console.info("close");

} catch (err) {
console.error("Swgger Gen Error", err);
}`

Link to code that reproduces the bug

No response

Expected Behavior

I would expect to be able to get an error message when my fastify.swagger fails, instead the process closed.

@mcollina
Copy link
Member

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.

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

No branches or pull requests

2 participants