Skip to content

fix: avoid node globals in debug logger - #474

Merged
hyochan merged 2 commits into
hyodotdev:mainfrom
jslok:fix/rn-iap-debug-node-globals
Sep 19, 2026
Merged

hyochan merged 2 commits into
hyodotdev:mainfrom
jslok:fix/rn-iap-debug-node-globals

Conversation

@jslok

@jslok jslok commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

React Native consumers type-check the library source through the react-native export condition. Without Node typings, the debug loggers fail on bare process and global references.

Read both development flags through typed globalThis in React Native and Expo. Opt-in logging stays the same, and a missing process or process.env is safe.

Verified: both original loggers reproduce the missing-Node-types error; both updated loggers compile with types: []. All 16 isolated runtime cases pass, including disabled logging, both opt-in switches, and unconditional warnings/errors. Lint, TypeScript, and 1,320 React Native/Expo library, plugin, and Expo example tests pass.

Preview: no visual surface; the checks above exercise the TypeScript failure and logger behavior directly.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b5e01f61-fb8e-4546-bed3-9e1538b3008b

📥 Commits

Reviewing files that changed from the base of the PR and between 7713ae1 and 352cc46.

📒 Files selected for processing (1)
  • libraries/expo-iap/src/utils/debug.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The React Native and Expo debug utilities now read development-mode settings through typed optional globalThis fields. Logging remains enabled when the relevant environment value is 'true' or the global flag is true.

Changes

Development mode access

Layer / File(s) Summary
Debug mode resolution
libraries/react-native-iap/src/utils/debug.ts, libraries/expo-iap/src/utils/debug.ts
Both utilities use globalThis to read optional environment values and global development-mode flags. The Expo utility removes runtime guards and the as any cast. Existing enablement checks remain unchanged.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: removing direct Node.js global references from the debug logger.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Sep 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.44%. Comparing base (78a6a91) to head (352cc46).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #474      +/-   ##
==========================================
+ Coverage   76.42%   76.44%   +0.01%     
==========================================
  Files         157      157              
  Lines       16714    16711       -3     
  Branches     4814     4811       -3     
==========================================
+ Hits        12773    12774       +1     
+ Misses       3941     3937       -4     
Flag Coverage Δ
expo-iap 90.72% <100.00%> (+0.21%) ⬆️
react-native-iap 93.11% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
React Native IAP 93.11% <100.00%> (+<0.01%) ⬆️
Expo IAP 90.72% <100.00%> (+0.21%) ⬆️
flutter_inapp_purchase 90.42% <ø> (ø)
IAPKit Server 92.03% <ø> (ø)
IAPKit Convex 61.97% <ø> (ø)
Files with missing lines Coverage Δ
libraries/expo-iap/src/utils/debug.ts 57.14% <100.00%> (+12.69%) ⬆️
libraries/react-native-iap/src/utils/debug.ts 100.00% <100.00%> (ø)
🚀 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.

expo-iap carries the same pattern as react-native-iap: a bare `process` and a
cast global in the debug logger. It does not fail a consumer build today,
because the package exposes only `build/` and its `.d.ts` — react-native-iap is
the one whose `react-native` export condition points at `src/index.ts`, so its
source is what a consumer type-checks.

Reading both through a typed `globalThis` matches the fix next door and keeps
the file compiling on its own, so a future source export cannot reintroduce it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hyochan hyochan added 🛠 bugfix All kinds of bug fixes ❄️ types Typing issues react-native-iap react-native-iap library expo-iap expo-iap library labels Sep 19, 2026
@hyochan
hyochan requested a balanced review from Copilot September 19, 2026 15:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused changes resolve the reported type errors without altering intended logging behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Removes Node-global type dependencies from debug loggers while preserving opt-in logging behavior.

Changes:

  • Accesses environment flags safely through typed globalThis.
  • Prevents consumer TypeScript failures when Node types are unavailable.
File Description
libraries/​react-native-iap/​src/​utils/​debug.ts Makes debug detection independent of Node typings.
libraries/​expo-iap/​src/​utils/​debug.ts Applies the same safe global access pattern.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@hyochan hyochan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified the missing-Node-types regression, both logging switches, and warning/error behavior. All relevant local tests and CI checks pass.

@hyochan
hyochan merged commit 4e8a699 into hyodotdev:main Sep 19, 2026
53 checks passed
@hyochan

hyochan commented Sep 19, 2026

Copy link
Copy Markdown
Member

Shipped in react-native-iap 16.6.2 and expo-iap 5.6.3 🚀

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

Labels

🛠 bugfix All kinds of bug fixes expo-iap expo-iap library react-native-iap react-native-iap library ❄️ types Typing issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants