Skip to content

Conversation

@joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Aug 7, 2025

Fixes BLD-76

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility for environments where the global process object is not defined, preventing potential runtime errors related to environment variable access.

@vercel
Copy link

vercel bot commented Aug 7, 2025

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

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2025 10:04am
nebula ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2025 10:04am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2025 10:04am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2025 10:04am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 7, 2025 10:04am

@changeset-bot
Copy link

changeset-bot bot commented Aug 7, 2025

🦋 Changeset detected

Latest commit: ec48402

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 7, 2025

Walkthrough

A conditional check for the existence of the global process object was added in several files to prevent runtime errors in environments where process is undefined. This change affects the assignment of certain constants that previously accessed process.env directly. No new features or exported entities were introduced.

Changes

Cohort / File(s) Change Summary
Add changeset for patch release
.changeset/chilly-lamps-post.md
Added a patch-level changeset describing the update to handle cases where process is undefined.
Safeguard process usage in zksync constants
packages/thirdweb/src/utils/any-evm/zksync/constants.ts
Updated the export of PUBLISHED_PRIVATE_KEY to check if process exists before accessing environment variables.
Safeguard process usage in environment detection
packages/thirdweb/src/utils/process.ts
Updated IS_DEV and IS_TEST constants to check for process existence before accessing process.env.NODE_ENV.

Sequence Diagram(s)

sequenceDiagram
    participant Runtime
    participant Code
    Note over Code: On constant initialization
    Runtime->>Code: Attempt to access process.env.*
    alt process is defined
        Code->>Code: Use process.env value
    else process is undefined
        Code->>Code: Assign undefined / skip access
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Assessment against linked issues

Objective Addressed Explanation
Prevent ReferenceError when process is not defined in app code (BLD-76)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

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.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ae2991 and ec48402.

📒 Files selected for processing (3)
  • .changeset/chilly-lamps-post.md (1 hunks)
  • packages/thirdweb/src/utils/any-evm/zksync/constants.ts (1 hunks)
  • 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/any-evm/zksync/constants.ts
  • 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/any-evm/zksync/constants.ts
  • packages/thirdweb/src/utils/process.ts
🧠 Learnings (8)
📚 Learning: applies to dashboard/**/*.{ts,tsx} : accessing server-only environment variables or secrets....
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{ts,tsx} : Accessing server-only environment variables or secrets.

Applied to files:

  • packages/thirdweb/src/utils/any-evm/zksync/constants.ts
  • packages/thirdweb/src/utils/process.ts
📚 Learning: applies to src/extensions/** : auto-generated contracts from abi definitions in extensions...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to src/extensions/** : Auto-generated contracts from ABI definitions in extensions

Applied to files:

  • packages/thirdweb/src/utils/any-evm/zksync/constants.ts
📚 Learning: applies to test/src/test-wallets.ts : predefined test accounts are in `test/src/test-wallets.ts`...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to test/src/test-wallets.ts : Predefined test accounts are in `test/src/test-wallets.ts`

Applied to files:

  • packages/thirdweb/src/utils/any-evm/zksync/constants.ts
📚 Learning: the thirdweb `contract` object is serializable and can safely be used in contexts (e.g., react-query...
Learnt from: MananTank
PR: thirdweb-dev/js#7332
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/nft/overview/nft-drop-claim.tsx:82-90
Timestamp: 2025-06-13T13:03:41.732Z
Learning: The thirdweb `contract` object is serializable and can safely be used in contexts (e.g., React-Query keys) that require serializable values.

Applied to files:

  • packages/thirdweb/src/utils/any-evm/zksync/constants.ts
📚 Learning: the thirdweb project has an eslint rule that restricts direct usage of `definechain`. when it's nece...
Learnt from: MananTank
PR: thirdweb-dev/js#7298
File: apps/dashboard/src/app/nebula-app/move-funds/move-funds.tsx:424-424
Timestamp: 2025-06-06T23:46:08.795Z
Learning: The thirdweb project has an ESLint rule that restricts direct usage of `defineChain`. When it's necessary to use `defineChain` directly, it's acceptable to disable the rule with `// eslint-disable-next-line no-restricted-syntax`.

Applied to files:

  • .changeset/chilly-lamps-post.md
📚 Learning: applies to **/*.test.{ts,tsx} : keep tests deterministic and side-effect free...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to **/*.test.{ts,tsx} : Keep tests deterministic and side-effect free

Applied to files:

  • packages/thirdweb/src/utils/process.ts
📚 Learning: applies to **/*.test.{ts,tsx} : use `forked_ethereum_chain` for mainnet interactions and `anvil_chai...
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to **/*.test.{ts,tsx} : Use `FORKED_ETHEREUM_CHAIN` for mainnet interactions and `ANVIL_CHAIN` for isolated tests

Applied to files:

  • packages/thirdweb/src/utils/process.ts
📚 Learning: when reviewing hooks that use environment variables like next_public_dashboard_thirdweb_client_id fo...
Learnt from: MananTank
PR: thirdweb-dev/js#7177
File: apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/public-pages/erc20/_hooks/useTokenTransfers.ts:41-44
Timestamp: 2025-05-27T19:56:16.920Z
Learning: When reviewing hooks that use environment variables like NEXT_PUBLIC_DASHBOARD_THIRDWEB_CLIENT_ID for API calls, MananTank prefers not to add explicit validation checks for these variables, trusting they will be set in the deployment environment.

Applied to 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). (7)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Size
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
packages/thirdweb/src/utils/process.ts (2)

2-3: LGTM! Proper safeguard against undefined process.

The addition of the process && check correctly prevents ReferenceError in environments where the global process object is not defined, such as certain browser environments or web workers.


5-5: LGTM! Consistent process guard implementation.

The same defensive pattern is correctly applied to IS_TEST, ensuring consistency across the file and preventing runtime errors in process-less environments.

.changeset/chilly-lamps-post.md (1)

1-6: LGTM! Properly documented changeset.

The changeset correctly specifies a patch-level update for the thirdweb package and clearly describes the purpose of the changes. The format follows changeset conventions.

packages/thirdweb/src/utils/any-evm/zksync/constants.ts (1)

6-8: LGTM! Consistent process guard with clean ternary implementation.

The ternary operator approach provides the same protection against undefined process while maintaining readability. The fallback to undefined is appropriate for an optional environment variable, ensuring the constant remains properly typed.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch _thirdweb_Handle_environments_where_process_is_not_defined

🪧 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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
  • 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 src/utils.ts and explain its main purpose.
    • @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 comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

Documentation and Community

  • 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.

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Aug 7, 2025
@joaquim-verges joaquim-verges changed the title [thirdweb] Handle environments where process is not defined [SDK] Handle environments where process is not defined Aug 7, 2025
Copy link
Member Author


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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@linear
Copy link

linear bot commented Aug 7, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Aug 7, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.15 KB (-0.01% 🔽) 1.3 s (-0.01% 🔽) 102 ms (-66.86% 🔽) 1.4 s
thirdweb (cjs) 352.97 KB (+0.01% 🔺) 7.1 s (+0.01% 🔺) 380 ms (-75.37% 🔽) 7.5 s
thirdweb (minimal + tree-shaking) 5.72 KB (+0.38% 🔺) 115 ms (+0.38% 🔺) 92 ms (+127.56% 🔺) 206 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 23 ms (+441.84% 🔺) 33 ms
thirdweb/react (minimal + tree-shaking) 19.29 KB (+0.17% 🔺) 386 ms (+0.17% 🔺) 64 ms (+141.25% 🔺) 449 ms

@codecov
Copy link

codecov bot commented Aug 7, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.33%. Comparing base (9ae2991) to head (ec48402).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ges/thirdweb/src/utils/any-evm/zksync/constants.ts 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7809      +/-   ##
==========================================
- Coverage   56.33%   56.33%   -0.01%     
==========================================
  Files         905      905              
  Lines       58806    58809       +3     
  Branches     4145     4143       -2     
==========================================
+ Hits        33130    33131       +1     
- Misses      25571    25573       +2     
  Partials      105      105              
Flag Coverage Δ
packages 56.33% <66.66%> (-0.01%) ⬇️
Files with missing lines Coverage Δ
packages/thirdweb/src/utils/process.ts 100.00% <100.00%> (ø)
...ges/thirdweb/src/utils/any-evm/zksync/constants.ts 95.12% <33.33%> (-4.88%) ⬇️
🚀 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.

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.

2 participants