Skip to content

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Nov 21, 2025

Description

Removing the custom variant for testing out BroadcastChannel functionality. This functionality is now part of the core browser build

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • Chores

    • Removed the BroadcastChannel build variant, associated dev script, and channel bundle tracking.
    • Added a changeset noting a minor release bump.
  • Refactor

    • Token cache now enables cross-tab communication based on environment capability rather than build variant.
    • Removed a previously exposed channel preset from the exported environment set.
  • Tests

    • Integration test environment switched from BroadcastChannel-based sharing to EmailCodes-based setup.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Nov 21, 2025

🦋 Changeset detected

Latest commit: 768e84d

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

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo 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

@vercel
Copy link

vercel bot commented Nov 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Nov 21, 2025 8:03pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

Walkthrough

Removed the clerkChannelBrowser build variant and related artifacts; switched BroadcastChannel usage from a build-time flag to runtime environment detection; updated presets, tests, build configs, and type declarations accordingly.

Changes

Cohort / File(s) Summary
Build config & scripts
packages/clerk-js/rspack.config.js, packages/clerk-js/bundlewatch.config.json, packages/clerk-js/package.json
Removed the clerkChannelBrowser build variant and all references, removed ./dist/clerk.channel.browser.js from bundlewatch, and deleted the dev:channel npm script.
Type & test config
packages/clerk-js/src/global.d.ts, packages/clerk-js/vitest.config.mts
Deleted the __BUILD_VARIANT_CHANNEL__ declaration/define from global types and Vitest config.
Runtime code
packages/clerk-js/src/core/tokenCache.ts
Replaced build-flag gated BroadcastChannel initialization with runtime environment detection (check for BroadcastChannel existence).
Integration presets & tests
integration/presets/envs.ts, integration/tests/session-token-cache/single-session.test.ts
Removed withBroadcastChannel from exported env presets and switched the single-session test to use the EmailCodes preset instead of BroadcastChannel.
Changeset
.changeset/curly-dingos-pay.md
Added a changeset noting a minor bump for @clerk/clerk-js describing session token poller optimization.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant TokenCache as TokenCache.ensureBroadcastChannel()
    participant Env as Runtime Environment
    participant BC as BroadcastChannel API

    rect rgb(220,240,255)
    note right of TokenCache: Old flow (build-time gated)
    App->>TokenCache: Initialize
    alt __BUILD_VARIANT_CHANNEL__ true
        TokenCache->>BC: instantiate & wire listener
        BC-->>TokenCache: ready
    else
        TokenCache-->>App: null (disabled)
    end
    end

    rect rgb(220,255,220)
    note right of TokenCache: New flow (runtime detection)
    App->>TokenCache: Initialize
    TokenCache->>Env: is BroadcastChannel defined?
    alt BroadcastChannel exists
        Env-->>TokenCache: yes
        TokenCache->>BC: instantiate & wire listener
        BC-->>TokenCache: ready
    else
        Env-->>TokenCache: no
        TokenCache-->>App: null (not available)
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Pay attention to packages/clerk-js/rspack.config.js to ensure no leftover references to the removed variant.
  • Verify tokenCache.ts handles environments without BroadcastChannel safely and that message handling remains correct.
  • Confirm integration test change properly reflects intended behavior and that integration/presets/envs.ts exports remain consistent.

Poem

🐰
I nudged the build flag from the burrow light,
Now channels wake when the day is right.
No variant keys, just the world outside—
Tokens hop through tabs, a smoother ride!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing the BroadcastChannel build variant. It directly reflects the core objective stated in the PR description and is specific about what is being removed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/remove-channel-variant

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d88197e and 768e84d.

📒 Files selected for processing (1)
  • .changeset/curly-dingos-pay.md (1 hunks)
⏰ 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). (34)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (nextjs, chrome, 15, RQ)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Unit Tests (22, shared, clerk-js, RQ)
  • GitHub Check: Static analysis
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
.changeset/curly-dingos-pay.md (1)

1-5: Clarify the changeset description and verify breaking change status.

The changeset description "Optimized session token poller to share token with other open tabs" doesn't clearly communicate the underlying infrastructure change (build variant removal + runtime environment detection). While the MINOR version bump is appropriate if functionality improves without API breakage, the description should better explain:

  1. What changed: BroadcastChannel detection moved from compile-time build variant to runtime environment detection
  2. Impact: Token sharing now works based on runtime capabilities rather than build variant selection
  3. Migration: Whether this affects existing build pipelines or requires any user action

Additionally, the PR checklist shows no type-of-change box checked. Verify whether this qualifies as a breaking change (if removing the clerkChannelBrowser variant breaks any documented workflows) or a feature/refactoring.

Consider revising the description to be more explicit about the change, or add clarifying context in clerk-docs (per the checklist) that explains the migration from build variants to runtime detection.


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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 21, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7288

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7288

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7288

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7288

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7288

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7288

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7288

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7288

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7288

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7288

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7288

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7288

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7288

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7288

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7288

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7288

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7288

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7288

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7288

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7288

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7288

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7288

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7288

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7288

commit: 768e84d

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants