Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the Requests for Startups (RFS) data fetching to use async/await patterns with fast-glob for better performance and modern JavaScript practices. It converts synchronous file system operations to asynchronous ones, simplifies error handling, and adds static generation configuration.
Changes:
- Migrated
getMarkdownSlugsandreadMarkdownFileto async/await usingfs/promisesandfast-glob - Refactored
buildFilePath(renamed fromvalidateSlugAndGetPath) to use object parameters and throw errors instead of returning null - Updated RFS data fetching functions to be async with simplified error handling
- Added empty state rendering and async support to the agents page component
- Configured
dynamicParams = falsefor static-only route generation
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/path-validation.ts | Refactored validation function to use object parameters, renamed to buildFilePath, changed to throw errors instead of returning null |
| src/utils/markdown.ts | Converted to async functions using fs/promises and fast-glob, removed security check and type exports |
| src/app/agents/utils/get-rfs-data.ts | Made functions async, extracted readRFSFile helper, removed verbose error logging and try-catch blocks |
| src/app/agents/page.tsx | Converted to async component, updated data access to use nested structure, added empty state conditional rendering |
| src/app/agents/[slug]/page.tsx | Added try-catch error handling to page component, made metadata generation async, added dynamicParams = false configuration |
| package.json | Added fast-glob dependency |
| package-lock.json | Added fast-glob and related dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Updated package-lock.json to include fast-glob (^3.3.3) as a dev dependency, along with its transitive dependencies like @nodelib/fs.* and micromatch components, likely for improved file globbing in build or tooling processes.
Replace synchronous fs.readdirSync with async fast-glob for better non-blocking I/O in Next.js server components. Update all callers (getRFSData, Agents page, and dynamic route) to use await for slugs retrieval. This prevents event loop blocking during file system reads in OPEN_REQUESTS_DIR.
…ty state Refactor RFS pages to use async/await for data loading in Next.js server components, improving reliability and UX. Wrap fetches in try-catch to log errors and invoke notFound() on failures. Add conditional rendering for empty open requests list. Set dynamicParams=false for static generation of known slugs. Update data access in list mapping to use nested 'data' property.
ddaddba to
cae3600
Compare
There was a problem hiding this comment.
@CharlyMartin Thanks so much for working on this. It looks great.
We still seemed to have some type issues so I pushed this CR - please feel free to make any changes directly if needed and merge this when done. I also rebased the branch.
🚀
📝 Description
This PR refactor RFS data fetching to use async/await with
fast-glob.🛠️ Key Changes
getMarkdownSlugsandreadMarkdownFileasync, replacing syncfswithfs/promisesandfast-glob[slug]/page.tsxwithnotFound()fallbackagents/page.tsxdynamicParams = falsefor static generation of known slugs onlyget-rfs-data.tsby extracting sharedreadRFSFilehelper and removing verbose error loggingpath-validation.ts: renamevalidateSlugAndGetPathtobuildFilePathwith object params, throw on invalid slugs instead of returning null🧪 How to Test
🔖 Resources