-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Fix SSR issues for SignalR: require is not defined #19832
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
Conversation
Thanks for the PR! You're a little too early because we're currently getting rid of I'll try to merge the change later today so you can rebase and apply this fix to the new code. |
Ok, change has been merged. Please rebase and update! |
@BrennanConroy I've rebased my branch and applied fixes also to the new FetchHttpClient. |
// Node needs EventListener methods on AbortController which our custom polyfill doesn't provide | ||
this.abortControllerType = requireFunc("abort-controller"); | ||
} else { | ||
this.fetchType = fetch.bind(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why call bind
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without calling bind
, it will cause error if you try to invoke fetch
:
Network error: TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
It seems to be a bug coming from fetch, where a binding is set incorrectly. Calling fetch.bind(self)
can resolve the problem, which will bind default fetch to "global" scope.
Any updates on this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any updates on this PR?
Sorry, was gone for a long weekend. Looks good!
Thanks for the PR @hez2010 ! |
Can I backport this fix to 3.1 release (see #21059 (comment))? Since it introduce no breaking changes. |
Fix SSR issues for SignalR: require is not defined.
Addresses #10400.