Skip to content

feat: Initialize supabase with custom websocket client #1145

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Vinzent03
Copy link
Collaborator

@Vinzent03 Vinzent03 commented Mar 31, 2025

What kind of change does this PR introduce?

feature

What is the current behavior?

Uses the implementation from dart:io for http.Client and WebSocketChannel.

What is the new behavior?

Use the classes provided by cupertino_http.

Additional context

I do not own a mac, so I cannot test this. So we can hopefully find a person to verify this actually works on iOS and macOS.

close #147

@Vinzent03 Vinzent03 changed the title feat: use cupertino http and websocket implementation feat: Use cupertino http and websocket implementation Mar 31, 2025
@coveralls
Copy link

coveralls commented Mar 31, 2025

Pull Request Test Coverage Report for Build 15667650391

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 8 (25.0%) changed or added relevant lines in 2 files are covered.
  • 142 unchanged lines in 6 files lost coverage.
  • Overall coverage increased (+5.2%) to 80.576%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/supabase/lib/src/supabase_client_options.dart 1 7 14.29%
Files with Coverage Reduction New Missed Lines %
packages/functions_client/lib/src/functions_client.dart 1 96.49%
packages/gotrue/lib/src/fetch.dart 1 91.36%
packages/gotrue/lib/src/gotrue_mfa_api.dart 2 97.53%
packages/gotrue/lib/src/gotrue_admin_api.dart 5 92.96%
packages/gotrue/lib/src/types/mfa.dart 18 80.43%
packages/gotrue/lib/src/gotrue_client.dart 115 64.77%
Totals Coverage Status
Change from base Build 14868379526: 5.2%
Covered Lines: 3103
Relevant Lines: 3851

💛 - Coveralls

@grdsdev
Copy link
Contributor

grdsdev commented Mar 31, 2025

@Vinzent03 we should make sure we run CI also on macOS, and test the package at least in a iOS build, just saw that we don't to that.

I created an issue for tracking that, #1146 feel free to pick it if you want, otherwise I can work on it later.

@Vinzent03
Copy link
Collaborator Author

I'm pretty sure to verify the behavior of the cupertino http client we can't just run the existing ci on a macos build in ci. For iOS we need flutter integration tests to actually run them on a iOS simulator. For macOS I'm unsure if the cupertino http client works if we run widget tests or actually need integratino tests as well. So we would need to write many additional tests sa well.

@grdsdev
Copy link
Contributor

grdsdev commented May 2, 2025

I see there is an examples folder in https://github.com/supabase/supabase-flutter/tree/main/packages/supabase_flutter/example

Probably just getting all these examples built in CI, would already solve the issue with checking if the library works on all available platforms.

@grdsdev
Copy link
Contributor

grdsdev commented May 5, 2025

Hey @Vinzent03 I just merged a few changes to CI, including builds on the macOS runner, can you rebase this PR?

@Vinzent03
Copy link
Collaborator Author

I think I could get this pr working, but (with the weird error on macos now as well) I'm unsure we really want this pr to land. I think one huge benefit of the supabase packages is the lack of native dependencies, unlike firebase. So the building is a lot let stressful. We already see some supabase unrelated issues because of app_links and its native part.

Since one can already replace the http client, I think it's a better and more composable implementation to allow a custom websocket client in supabase and supabase_flutter to be passed to realtime_client. And publish a guide on how to provide the native http clients. This also means less depencency managment for us. This way the first experience is easier with no native dependency stress, but if a user wants the native clients they can easily add them.
What do you think @dshukertjr @DanMossa

@DanMossa
Copy link
Collaborator

Big fan of just writing a quick example for others to use.

@dshukertjr
Copy link
Member

+1 on Dan here.

@Vinzent03
Copy link
Collaborator Author

@dshukertjr Do we want the documentation on how to integrate the cupertino/cronet http/websocket clients in the readme or on the docs website with a link to that in the readme?

The required changes I would note are:

  • Additional packages in the readme
  • Conditional import
  • The platform_http_io.dart file
  • The platform_http_web.dart file
  • The proper initialization of supabase with the methods from these files

@Vinzent03 Vinzent03 changed the title feat: Use cupertino http and websocket implementation feat: initialize supabase with custom websocket client Jun 12, 2025
@Vinzent03 Vinzent03 changed the title feat: initialize supabase with custom websocket client feat: Initialize supabase with custom websocket client Jun 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird errors related to connecting to the Supabase instance in Flutter
5 participants