Skip to content

Rewrite http redirects to be backward compatible with blazor redirects#1195

Merged
connor4312 merged 3 commits intomicrosoft:mainfrom
lewing:handle-blazor-redirect
Feb 8, 2022
Merged

Rewrite http redirects to be backward compatible with blazor redirects#1195
connor4312 merged 3 commits intomicrosoft:mainfrom
lewing:handle-blazor-redirect

Conversation

@lewing
Copy link
Member

@lewing lewing commented Feb 7, 2022

when a redirect occurs the WebSocket updates the url property so we read that in the error handler and replace http(s): with ws(s): and try one more time to connect

fixes #1190 here to support previous releases of the Blazor debugger

@lewing lewing changed the title Handle http redirect urls to be backward compatible with blazor redir… Rewrite http redirects to be backward compatible with blazor redirects Feb 8, 2022
const redirectedUrl = ws.url.replace(/^http:/, 'ws:').replace(/^https:/, 'wss:');

if (redirectedUrl === url) {
reject(errorEvent); // Parameter is an ErrorEvent. See https://github.com/websockets/ws/blob/master/doc/ws.md#websocketonerror
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously this was rejected with errorEvent.error, was the change intentional?

}

// Try to reconnect with the redirected URL
const redirectedSocket = new WebSocket(redirectedUrl, [], options);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest instead making a recursive call to the create method here so that timeout/cancellation is handled

@connor4312 connor4312 self-assigned this Feb 8, 2022
@lewing lewing force-pushed the handle-blazor-redirect branch from 7ed543b to 90f6c57 Compare February 8, 2022 16:34
@connor4312 connor4312 merged commit ef43c07 into microsoft:main Feb 8, 2022
connor4312 pushed a commit that referenced this pull request Feb 8, 2022
…irects (#1195)

* Handle http redirect urls to be backward compatible with blazor redirects

* Exit in the nonredirected case

* Call create recursively to handle cancellation
connor4312 pushed a commit that referenced this pull request Feb 8, 2022
…irects (#1195)

* Handle http redirect urls to be backward compatible with blazor redirects

* Exit in the nonredirected case

* Call create recursively to handle cancellation
@lewing lewing deleted the handle-blazor-redirect branch February 8, 2022 20:16
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.

Debug Blazor using Edge on Ubuntu

3 participants