Skip to content

Conversation

@gregfromstl
Copy link
Contributor

@gregfromstl gregfromstl commented Aug 12, 2025


PR-Codex overview

This PR focuses on fixing the resolution of the SDK in environments where process is undefined, ensuring that the code correctly checks for the existence of process and its properties.

Detailed summary

  • Modified the condition for IS_DEV to check if process is defined before accessing its properties.
  • Updated the condition for IS_TEST similarly to ensure process is defined before checking NODE_ENV.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes

    • Guarded environment checks to avoid runtime ReferenceErrors when Node globals are absent, improving stability across browsers, serverless, and edge runtimes.
    • More reliable detection of development and test modes, reducing unexpected crashes during bundling, CI testing, and client-side use.
  • Chores

    • Added release metadata so the fix will be published as a patch.

@gregfromstl gregfromstl requested review from a team as code owners August 12, 2025 17:11
@changeset-bot
Copy link

changeset-bot bot commented Aug 12, 2025

🦋 Changeset detected

Latest commit: 0d7e5e5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
thirdweb Patch
@thirdweb-dev/nebula Patch
@thirdweb-dev/wagmi-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

Walkthrough

Adds typeof process !== "undefined" guards to IS_DEV and IS_TEST in packages/thirdweb/src/utils/process.ts to avoid ReferenceError when process is unavailable; also adds a changeset file updating the package patch version.

Changes

Cohort / File(s) Summary of Changes
Environment guards update
packages/thirdweb/src/utils/process.ts
Added typeof process !== "undefined" guard to IS_DEV and IS_TEST; updated exported constant declarations to safely evaluate process.env in non-Node runtimes.
Changeset
.changeset/fine-zoos-own.md
Added changeset marking "thirdweb": patch with description: "Fix SDK resolution in environements where process is undefined".

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • TEAM-0000: Entity not found: Issue - Could not find referenced Issue.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/process-undefined-checks

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 12, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@vercel
Copy link

vercel bot commented Aug 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
docs-v2 Ready Preview Comment Aug 12, 2025 6:16pm
nebula Ready Preview Comment Aug 12, 2025 6:16pm
thirdweb_playground Ready Preview Comment Aug 12, 2025 6:16pm
thirdweb-www Ready Preview Comment Aug 12, 2025 6:16pm
wallet-ui Ready Preview Comment Aug 12, 2025 6:16pm

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Aug 12, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/thirdweb/src/utils/process.ts (1)

1-7: Optional: compute NODE_ENV once and derive flags from it

Reduces repeated property access and keeps the logic DRY while preserving behavior.

-export const IS_DEV =
-  typeof process !== "undefined" &&
-  process.env &&
-  (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test");
-
-export const IS_TEST = typeof process !== "undefined" && process.env && process.env.NODE_ENV === "test";
+const NODE_ENV =
+  typeof process !== "undefined" && process.env ? process.env.NODE_ENV : undefined;
+export const IS_DEV = NODE_ENV === "development" || NODE_ENV === "test";
+export const IS_TEST = NODE_ENV === "test";
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8665e8f and 50cdd85.

📒 Files selected for processing (1)
  • packages/thirdweb/src/utils/process.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

Files:

  • packages/thirdweb/src/utils/process.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • packages/thirdweb/src/utils/process.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Unit Tests
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
packages/thirdweb/src/utils/process.ts (3)

2-3: Robust guard prevents ReferenceError in non-Node runtimes — good change

Adding typeof process !== "undefined" before touching process.env is correct and solves Vite/browser crashes.


6-6: IS_TEST now correctly guarded and consistent with IS_DEV

This mirrors the new pattern and avoids runtime errors where process is absent.


1-7: Confirmed: All raw process. references are either in Node‐only contexts or properly guarded

  • Node scripts (scripts/hotlink/*.mjs), build/config files (vite.config.ts, vitest.config.ts) and test suites intentionally use process.* in a Node environment.
  • Runtime library code under packages/thirdweb/src only accesses process via the guarded helpers in:
    • utils/process.ts (checks typeof process !== "undefined" before using process.env)
    • utils/platform.ts (checks typeof process !== "undefined" before using process.versions)
    • utils/fetch.ts (uses IS_DEV/IS_TEST from process.ts, no raw process. calls)
  • React/Next.js applications reference process.env.* during build time via webpack/Next.js DefinePlugin, so no unguarded runtime process usage in browser bundles.

No unguarded process. calls remain in code that runs in the browser—no further changes needed.

@gregfromstl gregfromstl force-pushed the fix/process-undefined-checks branch from 26213c4 to 9999b08 Compare August 12, 2025 17:17
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/fine-zoos-own.md (1)

5-5: Fix typo and clarify the message (mention Vite).

Small polish to the changeset description for spelling and clarity.

Apply this diff:

-Fix SDK resolution in environements where process is undefined
+Fix SDK resolution in environments where `process` is not defined (e.g., Vite).
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50cdd85 and 9999b08.

📒 Files selected for processing (2)
  • .changeset/fine-zoos-own.md (1 hunks)
  • packages/thirdweb/src/utils/process.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/thirdweb/src/utils/process.ts
🧰 Additional context used
🪛 LanguageTool
.changeset/fine-zoos-own.md

[grammar] ~5-~5: Ensure spelling is correct
Context: ...dweb": patch --- Fix SDK resolution in environements where process is undefined

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Unit Tests
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.changeset/fine-zoos-own.md (1)

1-3: Changeset front-matter looks valid.

The package key and version bump type are correctly specified for Changesets.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 12, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.06 KB (+0.06% 🔺) 1.3 s (+0.06% 🔺) 251 ms (+523.69% 🔺) 1.6 s
thirdweb (cjs) 357.05 KB (-0.1% 🔽) 7.2 s (-0.1% 🔽) 726 ms (+377.91% 🔺) 7.9 s
thirdweb (minimal + tree-shaking) 5.73 KB (+0.14% 🔺) 115 ms (+0.14% 🔺) 78 ms (+1173.54% 🔺) 192 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 59 ms (+1731.8% 🔺) 69 ms
thirdweb/react (minimal + tree-shaking) 19.15 KB (-0.09% 🔽) 383 ms (-0.09% 🔽) 118 ms (+751.75% 🔺) 500 ms

@codecov
Copy link

codecov bot commented Aug 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.33%. Comparing base (8665e8f) to head (0d7e5e5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7844      +/-   ##
==========================================
- Coverage   56.34%   56.33%   -0.01%     
==========================================
  Files         905      905              
  Lines       58830    58834       +4     
  Branches     4149     4151       +2     
==========================================
- Hits        33147    33146       -1     
- Misses      25577    25582       +5     
  Partials      106      106              
Flag Coverage Δ
packages 56.33% <100.00%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
packages/thirdweb/src/utils/process.ts 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 12, 2025

Merge activity

<!--

## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes"

If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000):

## Notes for the reviewer

Anything important to call out? Be sure to also clarify these in your comments.

## How to test

Unit tests, playground, etc.

-->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR addresses the resolution of the SDK in environments where `process` is undefined, ensuring that the checks for development and test environments are more robust.

### Detailed summary
- Updated the `IS_DEV` constant to check if `process` is defined before accessing its properties.
- Modified the `IS_TEST` constant similarly to ensure it only evaluates when `process` is defined.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **Bug Fixes**
  * Guarded environment checks to avoid runtime errors where Node globals are absent, improving stability across browsers, serverless, and edge runtimes.
  * More reliable detection of development and test modes, reducing unexpected crashes during bundling, CI testing, and client-side use.

* **Chores**
  * Added release metadata so the fix will be published as a patch.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/fine-zoos-own.md (1)

5-5: Fix typo and improve clarity in changeset description.

Correct “environements” → “environments” and consider clarifying context (e.g., Vite) and wrapping process in backticks for readability.

Apply this diff:

-Fix SDK resolution in environements where process is undefined
+Fix SDK resolution in environments where `process` is undefined (e.g., Vite)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a01b90 and 0d7e5e5.

📒 Files selected for processing (2)
  • .changeset/fine-zoos-own.md (1 hunks)
  • packages/thirdweb/src/utils/process.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/thirdweb/src/utils/process.ts
🧰 Additional context used
🪛 LanguageTool
.changeset/fine-zoos-own.md

[grammar] ~5-~5: Ensure spelling is correct
Context: ...dweb": patch --- Fix SDK resolution in environements where process is undefined

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Build Packages
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
.changeset/fine-zoos-own.md (1)

1-3: Changeset frontmatter looks correct.

Patch bump for "thirdweb" is appropriate for this fix.

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

Labels

packages SDK Involves changes to the thirdweb SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants