Skip to content

Commit 7eda030

Browse files
authored
fix: return when an error is downplayed (#708)
* fix: return when an error is downplayed * lint * changeset * review
1 parent 9e770b5 commit 7eda030

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/orange-impalas-repeat.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@opennextjs/aws": patch
3+
---
4+
5+
fix: add early return for downplayed aws-sdk errors
6+
7+
In the logger adapter:
8+
9+
An issue was identified where downplayed errors from the aws-sdk client (f.ex NoSuchKey from S3) would not return from the function early. This caused unnecessary invocation of `console.error` outside the conditional.

packages/open-next/src/adapters/logger.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ const isDownplayedErrorLog = (errorLog: AwsSdkClientCommandErrorLog) =>
4343
export function error(...args: any[]) {
4444
// we try to catch errors from the aws-sdk client and downplay some of them
4545
if (args.some((arg) => isDownplayedErrorLog(arg))) {
46-
debug(...args);
47-
} else if (args.some((arg) => isOpenNextError(arg))) {
46+
return debug(...args);
47+
}
48+
if (args.some((arg) => isOpenNextError(arg))) {
4849
// In case of an internal error, we log it with the appropriate log level
4950
const error = args.find((arg) => isOpenNextError(arg))!;
5051
if (error.logLevel < getOpenNextErrorLogLevel()) {

0 commit comments

Comments
 (0)