This repository serves as a minimal reproduction of a bug in expo-web-browser and includes the pre-packaged fix for verification.
Related PR: expo/expo#41179
The Issue:
On the web, when WebBrowser.openBrowserAsync() is blocked by the browser (e.g., inside in-app browsers like Instagram/Facebook or when triggered without a user gesture), it incorrectly resolves with { type: "opened" } instead of throwing an error.
The Fix:
This repository includes a local build (.tgz) of the modified expo-web-browser package that correctly checks for blocked popups and throws ERR_WEB_BROWSER_BLOCKED.
- App Code: A minimal Expo app that triggers
openBrowserAsyncon mount (simulating a blocked popup). - Patched Package:
expo-web-browser-xx.x.x.tgz(Located in the root). This contains the fix applied in the PR.
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/expo-web-browser-blocked-popup-repro.git cd expo-web-browser-blocked-popup-repro/test-app -
Install dependencies: This will automatically install the included patched version of
expo-web-browserfrom the local.tgzfile.npm install
-
Run on web:
npx expo start --web
-
Verify the Fix:
- The included
.tgz(expo-web-browser-15.0.7.tgz) will not be automatically installed bynpm installwhen running in thetest-appfolder.
Install it manually using one of the commands below from the
test-appdirectory:-
npm install ./expo-web-browser-15.0.7.tgz -
npm install /full/path/to/expo-web-browser-15.0.7.tgz -
Or run
npm installthen drag-and-drop theexpo-web-browser-15.0.7.tgzfile into your terminal to paste the path, then press Enter. -
To reproduce a blocked popup you can either enable your browser's popup blocking or run the app in Incognito/Private mode (which often blocks automatic popups).
Steps to Block Popups in Common Browsers
Browser Steps to Block Popups Chrome Settings → Privacy and security → Site Settings → Pop-ups and redirects → set to Blocked Safari (macOS) Safari → Settings → Websites → Pop-up Windows → choose Block for the site or When visiting other websites: Block Firefox Preferences → Privacy & Security → Permissions → check Block pop-up windows Note: You can also test inside in-app browsers (Instagram/Facebook), where popups are often blocked by design.
The test app triggersWebBrowser.openBrowserAsync()automatically on mount to simulate the condition.-
Expected Result: The popup is blocked and the app displays
"BLOCKED! Error caught: ERR_WEB_BROWSER_BLOCKED"(or shows an error alert), indicating the patchedexpo-web-browsercorrectly detects blocked popups.|After.mov
-
Without the fix, the app will often display
"FAILED TO BLOCK"because the library incorrectly returns a success result even when the browser blocked the popup.Before.mov
- The included
| Feature | Without Fix (Current Behavior) | With Fix (Patched) |
|---|---|---|
| Scenario | window.open() is blocked by the browser (e.g., inside Instagram/Facebook or no user gesture). |
window.open() is blocked by the browser. |
| Result | Silent Failure. Resolves with { type: "opened" } as if it succeeded. |
Error Thrown. Rejects with ERR_WEB_BROWSER_BLOCKED. |
| User Exp | App thinks popup opened; User sees nothing. | App catches error; User gets a fallback/alert. |