question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SignalR TypeScript client throws `AbortController is undefined` on older browsers

See original GitHub issue

Describe the bug

Hey everyone! I have a weird issue that I think is easily solvable with the SignalR. We have an app that runs on SmartTV web browsers, and through a bit of investigation, I learned it should be based on Chromium 56 (I know…).

We recently updated our SignalR packages and discovered that our SignalR hubs failed to connect on these TVs due to AbortController is undefined.

I traced the error to https://github.com/dotnet/aspnetcore/blob/8e65e6034dc0f4cc47c0cfbc5a88a135afb2508e/src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts#L40

https://github.com/dotnet/aspnetcore/blob/8e65e6034dc0f4cc47c0cfbc5a88a135afb2508e/src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts#L23-L42

Turns out on some of these older browsers (I’m not exactly sure how many), fetch is available but they do not implement AbortController. This looks like what is causing our issue.

As a workaround, I did a check in my application before SignalR attempted connection:

if (typeof fetch !== "undefined" && typeof AbortController === "undefined") {
  console.warn("Fetch is supported, but not AbortController.  Dropping default fetch so SignalR can override.");
  window.fetch = undefined;
}

On the older browsers, this worked perfectly as it disabled the built-in fetch mechanic and caused SignalR to fallback to its polyfill. But I don’t necessarily think this needs to be an app-wide fix although it didn’t seem to affect Axios which we use for other fetch related functions.

I think it might be more useful for this check: https://github.com/dotnet/aspnetcore/blob/8e65e6034dc0f4cc47c0cfbc5a88a135afb2508e/src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts#L40

to be updated to

if (typeof fetch === "undefined" || typeof AbortController === "undefined") {

To Reproduce

I was able to reproduce and debug by taking any SignalR TypeScript client and running it inside of Chrome 56 (via Browserstack).

Exceptions (if any)

Further technical details

  • ASP.NET Core 5
  • SignalR TypeScript 5.0.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
BrennanConroycommented, Mar 1, 2021

Closing the issue as we have no planned work here. Feel free to open a PR and reference this issue.

0reactions
1kevgriffcommented, Feb 25, 2021

@BrennanConroy Yeah, I completely understand. I believe the change is subtle enough to keep everything else working fine while still allowing support for some of these older browsers.

I’ll set up a PR shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SignalR AbortController is Undefined on Older Browsers
Recently, I updated a client application to the latest versions of SignalR (including the NPM module). One of our users uses a SmartTV...
Read more >
AbortController is undefined in IE11 · Issue #29424
Describe the bug Although signalr has ponyfill for AbortController, its not being used in FetchHttpClient. This leads to error in IE11 where ...
Read more >
Why is AbortController not defined? - javascript
I tried to create AborterController in a browser and same error. Chrome. Why it doesn't support new AbortController() ? – karolis2017. Apr 17, ......
Read more >
SignalR Troubleshooting
This article describes some common issues with developing SignalR applications.
Read more >
ASP.NET Core SignalR JavaScript client
The invoke method returns a JavaScript Promise . The Promise is resolved with the return value (if any) when the method on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found