Skip to content

fix: infinite recursion in getReferrer() crashing all pages#162

Merged
Hugo0 merged 1 commit into
mainfrom
fix-getreferrer-recursion
Mar 14, 2026
Merged

fix: infinite recursion in getReferrer() crashing all pages#162
Hugo0 merged 1 commit into
mainfrom
fix-getreferrer-recursion

Conversation

@Hugo0

@Hugo0 Hugo0 commented Mar 14, 2026

Copy link
Copy Markdown
Owner

URGENT

getReferrer() in analytics.ts calls itself instead of document.referrer, causing RangeError: Maximum call stack size exceeded. This crashes the Vue app on ALL pages — the homepage shows no languages, game pages don't load.

Fix

-const getReferrer = (): string => getReferrer();
+const getReferrer = (): string => document.referrer || 'direct';

Introduced in PR #159 (slim GA4 refactor) — the replace_all edit that replaced document.referrer || 'direct' with getReferrer() also caught the function definition itself.

Summary by CodeRabbit

Bug Fixes

  • Fixed an issue where analytics referrer tracking was causing crashes. Referrer data is now properly captured for analytics functionality.

getReferrer was calling itself instead of document.referrer.
This caused RangeError: Maximum call stack size exceeded,
preventing the Vue app from mounting on all pages.
@coderabbitai

coderabbitai Bot commented Mar 14, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8837ae37-a2f7-4d26-aa13-b8a854cfdbff

📥 Commits

Reviewing files that changed from the base of the PR and between 6072ff4 and 8e7e12e.

📒 Files selected for processing (1)
  • frontend/src/analytics.ts

📝 Walkthrough

Walkthrough

A self-recursive bug in the getReferrer function is fixed by replacing the erroneous recursive call with direct document.referrer retrieval, falling back to 'direct' when unavailable. This single-line fix resolves infinite recursion behavior.

Changes

Cohort / File(s) Summary
Analytics Referrer Fix
frontend/src/analytics.ts
Fixed self-recursive call in getReferrer function; now directly retrieves document.referrer with 'direct' fallback instead of infinitely recursing.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A rabbit found a loop of endless dread,
Where getReferrer chased its own head,
One line was swapped, the recursion ceased,
Now document.referrer's finally released! 🎉

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-getreferrer-recursion
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

@Hugo0
Hugo0 merged commit fc32bfb into main Mar 14, 2026
4 checks passed
@Hugo0
Hugo0 deleted the fix-getreferrer-recursion branch April 15, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant