-
Notifications
You must be signed in to change notification settings - Fork 63
feat: log API errors in non-production environments #763
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
base: canary
Are you sure you want to change the base?
Conversation
commit: |
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.
1 issue found across 1 file
Prompt for AI agents (all 1 issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/resend.ts">
<violation number="1" location="src/resend.ts:77">
P2: `process.env` is accessed without guarding that `process` exists, so any non-Node runtime (e.g., Cloudflare Workers) will throw a ReferenceError as soon as an error response goes through this branch. Guard the `process` access before checking `NODE_ENV`, and apply the same guard to the other new logging blocks.</violation>
</file>
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
src/resend.ts
Outdated
| const rawError = await response.text(); | ||
| const parsedError = JSON.parse(rawError); | ||
|
|
||
| if (process.env.NODE_ENV !== 'production') { |
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.
P2: process.env is accessed without guarding that process exists, so any non-Node runtime (e.g., Cloudflare Workers) will throw a ReferenceError as soon as an error response goes through this branch. Guard the process access before checking NODE_ENV, and apply the same guard to the other new logging blocks.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/resend.ts, line 77:
<comment>`process.env` is accessed without guarding that `process` exists, so any non-Node runtime (e.g., Cloudflare Workers) will throw a ReferenceError as soon as an error response goes through this branch. Guard the `process` access before checking `NODE_ENV`, and apply the same guard to the other new logging blocks.</comment>
<file context>
@@ -72,21 +72,41 @@ export class Resend {
const rawError = await response.text();
+ const parsedError = JSON.parse(rawError);
+
+ if (process.env.NODE_ENV !== 'production') {
+ console.error('[Resend API Error]:', {
+ status: response.status,
</file context>
| if (process.env.NODE_ENV !== 'production') { | |
| if ( | |
| typeof process !== 'undefined' && | |
| process.env && | |
| process.env.NODE_ENV !== 'production' | |
| ) { |
fc6c355 to
401471d
Compare
rehanvdm
left a comment
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.
Is this just to have better observability? And make it easier to debug by not adding many console logs?
Summary by cubic
Adds structured console logging for Resend API errors in non-production to make debugging easier. Production behavior is unchanged.
Written for commit 401471d. Summary will update automatically on new commits.