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
fix: add more error info on missing functions folders #1134
Conversation
export const listFunctionsDirectory = async function (srcFolder: string) { | ||
try { | ||
const filenames = await fs.readdir(srcFolder) | ||
const listFunctionsDirectory = async function (srcFolder: string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the export as it is nowhere used outside this file, and also is not a Public API.
⏱ Benchmark resultsComparing with cd082fc largeDepsEsbuild: 5.7s⬇️ 4.85% decrease vs. cd082fc
LegendlargeDepsNft: 28s⬇️ 6.32% decrease vs. cd082fc
LegendlargeDepsZisi: 42.9s⬇️ 4.47% decrease vs. cd082fc
|
return filenames.map((name) => join(srcFolder, name)) | ||
} catch { | ||
throw new Error(`Functions folder does not exist: ${srcFolder}`) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we do not export it we do not need to catch anymore, because the error will be matched in the function above.
srcFolders.map(async (srcFolder) => { | ||
try { | ||
const filenames = await listFunctionsDirectory(srcFolder) | ||
const filenamesByDirectory = await Promise.allSettled( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allSettled
is available as of node 12.9.0
bc5a643
to
ab2ef31
Compare
src/utils/fs.ts
Outdated
const validDirectories = filenamesByDirectory | ||
.map((result) => { | ||
if (result.status === 'rejected') { | ||
if (result.reason instanceof Error && (result.reason as NodeJS.ErrnoException).code !== 'ENOENT') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason Error does not contain code
, so this is the workaround.
🎉 Thanks for submitting a pull request! 🎉
Summary
For https://github.com/netlify/pod-compute/issues/108
Throws underlying errors if the error is not a FileNotFound Error.