-
Notifications
You must be signed in to change notification settings - Fork 22
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
Conversation
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.) |
the pr has multiple changes already merged to main or unrelated can you fix this please, it would help with the review |
@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
9a738ae
to
1fbc254
Compare
@hugomrdias Rebased this against current main, so it now shows just the small patch needed. |
i created this PR storacha/ucanto#214 in ucanto to avoid the custom types here |
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. |
Ah sweet - I like this approach @alanshaw - will update and get it moving |
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`.
closing in favor of #440 |
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!
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!
🤖 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>
🤖 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>
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 theAgent
relying exclusive on itsthis.connection
for all actual transport, it also cheats and creates its ownnew Websocket(…)
on the side!That extra websocket is the only reason the
Agent
instance keeps a copy ofthis.url
at all — everything else goes through the properConnectionView<Service>
abstraction. So I believe thew3ui
code is fulfilling its side of the interface contract. Since it is theAgent
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.