Skip to content

Conversation

@vieiralucas
Copy link
Member

@vieiralucas vieiralucas commented Dec 1, 2025

Summary by cubic

Adds structured console logging for Resend API errors in non-production to make debugging easier. Production behavior is unchanged.

  • New Features
    • Logs “[Resend API Error]” with status, error payload, and path when API calls fail (non-production only).
    • Normalizes error objects for JSON parse failures, generic errors, and network errors.
    • Logging gated by NODE_ENV !== 'production'.

Written for commit 401471d. Summary will update automatically on new commits.

@vieiralucas vieiralucas requested a review from a team as a code owner December 1, 2025 11:02
@vieiralucas vieiralucas requested a review from rehanvdm December 1, 2025 11:02
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 1, 2025

Open in StackBlitz

npm i https://pkg.pr.new/resend/resend-node/resend@763

commit: 401471d

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a 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') {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Dec 1, 2025

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 !== &#39;production&#39;) {
+            console.error(&#39;[Resend API Error]:&#39;, {
+              status: response.status,
</file context>
Suggested change
if (process.env.NODE_ENV !== 'production') {
if (
typeof process !== 'undefined' &&
process.env &&
process.env.NODE_ENV !== 'production'
) {
Fix with Cubic

@vieiralucas vieiralucas force-pushed the feat/error-logging-non-production branch from fc6c355 to 401471d Compare December 1, 2025 12:11
Copy link

@rehanvdm rehanvdm left a 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants