-
Notifications
You must be signed in to change notification settings - Fork 295
Warn in the TypeScript Client when using HTTP for shape URLs. #3661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
HTTP (not HTTPS) forces HTTP/1.1 in browsers, which limits concurrent connections to 6 per domain. This can cause slow shapes and app freezes when using multiple shapes. Add a console.warn to alert developers about this limitation and link to documentation for setting up HTTPS/HTTP2.
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3661 +/- ##
==========================================
+ Coverage 87.91% 87.96% +0.05%
==========================================
Files 22 22
Lines 1820 1845 +25
Branches 459 469 +10
==========================================
+ Hits 1600 1623 +23
- Misses 218 220 +2
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
Tests verify that: - HTTP URLs trigger a console.warn in browser environments - HTTPS URLs do not trigger the warning - Non-browser environments (no window) do not trigger the warning
Add vitest setup file that filters the Electric HTTP warning to avoid spamming test output. The warning is still tested explicitly in stream.test.ts.
Users can now pass `warnOnHttp: false` to suppress the browser console warning about HTTP URLs limiting concurrent connections. Test setup filters all [Electric] prefixed warnings to keep logs clean.
- Guard process.env.NODE_ENV access with typeof check to prevent ReferenceError in browser builds where process is not defined - Add relative URL handling using window.location.href as base, so relative URLs like /v1/shape now correctly trigger warnings when the page is served over HTTP - Add module-level didWarnOnHttp flag to warn only once per process/module, preventing log spam with multiple ShapeStreams - Update warning wording to "typically limits browsers to ~6 concurrent connections per origin under HTTP/1.1" - Replace bit.ly short link with canonical docs URL https://electric-sql.com/r/electric-http2 - Add redirect in website _redirects for /r/electric-http2 - Add comprehensive tests for relative URL behavior and warn-once - Properly clean up test globals (delete window if not present)
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@KyleAMathews addressed (and read code and tested in browser). |
Summary
Changes
packages/typescript-client/src/client.ts: Added defensive check invalidateOptions()that warns about HTTP URLs in browser environmentspackages/typescript-client/test/stream.test.ts: Added unit tests verifying: