Skip to content

🎥 Make videos programmatically with React

fix ENOENT error

Jonny Burger980265d905e2
diff --git a/packages/docs/docs/lambda-changelog.md b/packages/docs/docs/lambda-changelog.md
index a5dd859f6d..38f4565a0c 100644
--- a/packages/docs/docs/lambda-changelog.md
+++ b/packages/docs/docs/lambda-changelog.md
@@ -23,6 +23,10 @@ Refactor of the Lambda layer architecture to bring the following benefits:
- Removed the need for `lambda:ListLayers`, `lambda:DeleteLayerVersion`, `lambda:GetLayerVersion` and `lambda:PublishLayerVersion` permission.
- Removed the need to call `ensureLambdaBinaries()`. The function and docs for it have been deleted, remove it from your implementation as well. You also don't need to pass `layerArn` to `deployFunction` anymore either.
+Also:
+
+- Fixed a bug where a `ENOENT` exception could be thrown during render
+
## October 1th, 2021
Version hash: `2.5.0-alpha.b52a746f`
diff --git a/packages/lambda/src/functions/helpers/get-files-in-folder.ts b/packages/lambda/src/functions/helpers/get-files-in-folder.ts
index 73018f5da7..63f6b77378 100644
--- a/packages/lambda/src/functions/helpers/get-files-in-folder.ts
+++ b/packages/lambda/src/functions/helpers/get-files-in-folder.ts
@@ -11,14 +11,23 @@ export function getFolderFiles(folder: string) {
const paths: FileNameAndSize[] = [];
files.forEach((file) => {
const full = path.join(folder, file);
- const stat = fs.statSync(full);
- if (stat.isDirectory()) {
- paths.push(...getFolderFiles(full));
- } else {
- paths.push({
- filename: full,
- size: stat.size,
- });
+ try {
+ const stat = fs.statSync(full);
+ if (stat.isDirectory()) {
+ paths.push(...getFolderFiles(full));
+ } else {
+ paths.push({
+ filename: full,
+ size: stat.size,
+ });
+ }
+ } catch (err) {
+ if ((err as Error).message.includes('ENOENT')) {
+ // Race condition: File was deleted in the meanwhile.
+ // Do nothing
+ } else {
+ throw err;
+ }
}
});
return paths;