From ccd373171f2f043139fc1946c06d37451158bc9c Mon Sep 17 00:00:00 2001 From: badMade <106821302+badMade@users.noreply.github.com> Date: Sat, 23 May 2026 14:53:10 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Replace=20fs.readFileSync?= =?UTF-8?q?=20with=20async=20fs.promises.readFile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the synchronous `fs.readFileSync` in `src/init-server.ts` with the asynchronous `fs.promises.readFile` inside `loadOpenApiSpec`. This prevents the event loop from being blocked while loading the OpenAPI specification file. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> --- .jules/bolt.md | 3 +++ src/init-server.ts | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..c050b589 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2024-05-23 - [File Read Opt] +**Learning:** Prefer `await fs.promises.readFile` over `fs.readFileSync` for reading files inside async functions, to avoid blocking the event loop and improve server performance. +**Action:** Replace `fs.readFileSync` with `await fs.promises.readFile` in `src/init-server.ts`. diff --git a/src/init-server.ts b/src/init-server.ts index d459fe7d..28aad4b3 100644 --- a/src/init-server.ts +++ b/src/init-server.ts @@ -17,7 +17,8 @@ async function loadOpenApiSpec(specPath: string, baseUrl: string | undefined): P let rawSpec: string try { - rawSpec = fs.readFileSync(path.resolve(process.cwd(), specPath), 'utf-8') + // ⚡ Bolt Optimization: Use async readFile instead of readFileSync to avoid blocking the event loop during initialization + rawSpec = await fs.promises.readFile(path.resolve(process.cwd(), specPath), 'utf-8') } catch (error) { console.error('Failed to read OpenAPI specification file:', (error as Error).message) process.exit(1)