You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Direct access and require of process caused issue in Next.js builds. Needed a safer way to do environment detection. Used pattern already present in websocket-factory.
The changes add Jest setup configuration to globally expose the require function and modify platform/runtime detection in the client constants to use dynamic property access and environment-aware checks, avoiding bundler static analysis issues while ensuring proper server-side detection.
Changes
Cohort / File(s)
Summary
Jest Configuration packages/core/supabase-js/jest.config.ts, packages/core/supabase-js/jest.setup.ts
Added setupFilesAfterEnv entry to Jest config to load setup script. New jest.setup.ts polyfill exposes globalThis.require when ts-jest doesn't provide it, ensuring require is accessible during tests.
Replaced direct process global access with dynamic property access via (globalThis as any)['process'] to prevent bundler static analysis. Added platform checks for android and iOS, conditional require('os') for server-side Node contexts, and null-safe guards around process usage.
Test Updates packages/core/supabase-js/test/unit/constants.test.ts
Renamed test and refactored to add explicit server-side environment guards (typeof window === 'undefined'). Ensures platformVersion and runtimeVersion assertions run only in non-browser environments.
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
🐰 Hops through the code with glee, Dynamic properties dance so free, Jest setup blooms, platform checks grow, Bundlers deceived—now the truth they'll know! ✨
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.
Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name
Status
Explanation
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
✅ Passed
The title accurately describes the main change: refactoring environment detection to use bracket notation for accessing require and process properties to fix build issues.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
📝 Generate docstrings
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.
mandarini
changed the title
fix(supabase): environment detection require in brackets
fix(supabase): safe environment detection node v browser
Jan 26, 2026
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
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.
Direct access and require of process caused issue in Next.js builds. Needed a safer way to do environment detection. Used pattern already present in websocket-factory.
Fix for issue caused by #2046
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.