feat: log API errors in non-production environments#763
Open
vieiralucas wants to merge 1 commit intocanaryfrom
Open
feat: log API errors in non-production environments#763vieiralucas wants to merge 1 commit intocanaryfrom
vieiralucas wants to merge 1 commit intocanaryfrom
Conversation
commit: |
Contributor
There was a problem hiding this comment.
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') { |
Contributor
There was a problem hiding this comment.
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>
Suggested change
| if (process.env.NODE_ENV !== 'production') { | |
| if ( | |
| typeof process !== 'undefined' && | |
| process.env && | |
| process.env.NODE_ENV !== 'production' | |
| ) { |
fc6c355 to
401471d
Compare
rehanvdm
approved these changes
Dec 8, 2025
rehanvdm
left a comment
There was a problem hiding this comment.
Is this just to have better observability? And make it easier to debug by not adding many console logs?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.