Skip to content
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

fix: inconsistent w3ui custom URL handling #404

Closed
wants to merge 2 commits into from

Conversation

natevw
Copy link
Contributor

@natevw natevw commented Jan 27, 2023

This is imo the cleanest way of resolving issue #344, where a custom server URL is used only for the individual HTTP requests and not for the corresponding WebSocket connection.

It took a while to decide the best place to fix this. For a little while, it seemed like the internals of createAgent() within @w3ui/keyring-core needed to copy out the URL into its the top-level options. But ultimately I believe that would be an incorrect workaround!

The root cause is that @web3-storage/access/agent is pulling some tricks on its own that get it into trouble: instead of the Agent relying exclusive on its this.connection for all actual transport, it also cheats and creates its own new Websocket(…) on the side!

That extra websocket is the only reason the Agent instance keeps a copy of this.url at all — everything else goes through the proper ConnectionView<Service> abstraction. So I believe the w3ui code is fulfilling its side of the interface contract. Since it is the Agent that bypasses the abstraction, it is responsible to look for the raw URL inside of it.

This ends up being a relatively trivial code change, but did require some special (internal) extensions to the type definitions to support.

@natevw
Copy link
Contributor Author

natevw commented Jan 27, 2023

Looks like @alanshaw and @hugomrdias might be good reviewers for this? (And if this PR is approved please do the merge too, since I do not have write access.)

@hugomrdias
Copy link
Contributor

the pr has multiple changes already merged to main or unrelated can you fix this please, it would help with the review

@natevw
Copy link
Contributor Author

natevw commented Jan 31, 2023

@hugomrdias D'oh! Good catch, not sure why that happened but was definitely not my intent… will clean this up.

this is one way of resolving issue storacha#344, where a custom server URL is used only for the individual HTTP requests and not for the corresponding WebSocket connection
this also adds additional notes/documentation explaining the situation
@nate-dag nate-dag force-pushed the nvw/fix-wsClientUrl branch from 9a738ae to 1fbc254 Compare January 31, 2023 20:34
@natevw
Copy link
Contributor Author

natevw commented Jan 31, 2023

@hugomrdias Rebased this against current main, so it now shows just the small patch needed.

@hugomrdias
Copy link
Contributor

i created this PR storacha/ucanto#214 in ucanto to avoid the custom types here

@heyjay44 heyjay44 added this to the w3up phase 3 milestone Feb 15, 2023
@alanshaw
Copy link
Member

IMHO we should just lose the additional types here to get this mergable. We can do something like storacha/ucanto#214 (comment) if we really need to appease typescript.

@travis
Copy link
Member

travis commented Feb 21, 2023

Ah sweet - I like this approach @alanshaw - will update and get it moving

@travis travis requested review from alanshaw and removed request for hugomrdias February 21, 2023 07:41
@travis travis self-assigned this Feb 21, 2023
travis added a commit that referenced this pull request Feb 21, 2023
This fixes #344 and makes it possible to connect to staging services with w3ui.

This PR obsoletes #404 per @alanshaw's suggestion in #404 (comment) based on reasoning in storacha/ucanto#214 (comment) which points out that some sort of conditional or casting is probably unavoidable here.

My solution casts the channel to have an optional `url` field and looks in that field for a URL before falling back to the default `HOST`.
@travis
Copy link
Member

travis commented Feb 21, 2023

closing in favor of #440

@travis travis closed this Feb 21, 2023
travis added a commit that referenced this pull request Feb 21, 2023
This fixes #344 and
makes it possible to connect to staging services with w3ui.

This PR obsoletes #404
per @alanshaw's suggestion in
#404 (comment)
based on reasoning in
storacha/ucanto#214 (comment)
which points out that some sort of conditional or casting is probably
unavoidable here.

My solution casts the channel to have an optional `url` field and looks
in that field for a URL before falling back to the default `HOST`.

Have tested this locally with w3ui and verified it makes it possible to
connect to staging services from w3ui - huzzah!
gobengo pushed a commit that referenced this pull request Apr 11, 2023
This fixes #344 and
makes it possible to connect to staging services with w3ui.

This PR obsoletes #404
per @alanshaw's suggestion in
#404 (comment)
based on reasoning in
storacha/ucanto#214 (comment)
which points out that some sort of conditional or casting is probably
unavoidable here.

My solution casts the channel to have an optional `url` field and looks
in that field for a URL before falling back to the default `HOST`.

Have tested this locally with w3ui and verified it makes it possible to
connect to staging services from w3ui - huzzah!
Peeja pushed a commit to storacha/upload-service that referenced this pull request Jan 17, 2025
🤖 I have created a release *beep* *boop*
---


##
[4.0.0](storacha/w3ui@vue-uploader-v3.0.1...vue-uploader-v4.0.0)
(2023-03-23)


### ⚠ BREAKING CHANGES

* use new account model
([storacha#400](storacha/w3ui#400))

### Features

* use new account model
([storacha#400](storacha/w3ui#400))
([66dd20b](storacha/w3ui@66dd20b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Travis Vachon <travis@dag.house>
Peeja pushed a commit to storacha/upload-service that referenced this pull request Jan 29, 2025
🤖 I have created a release *beep* *boop*
---


##
[4.0.0](storacha/w3ui@vue-uploader-v3.0.1...vue-uploader-v4.0.0)
(2023-03-23)


### ⚠ BREAKING CHANGES

* use new account model
([storacha#400](storacha/w3ui#400))

### Features

* use new account model
([storacha#400](storacha/w3ui#400))
([b594536](storacha/w3ui@b594536))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Travis Vachon <travis@dag.house>
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.

access-client Agent.url defaults to HOST even when custom connection is used
5 participants