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

SignalR Message Pack Client Library not running in browser when using Angular Cli #9687

Closed
QuinntyneBrown opened this issue Apr 23, 2019 · 18 comments
Assignees
Labels
affected-few This issue impacts only small number of customers area-signalr Includes: SignalR clients and servers bug This issue describes a behavior which is not expected - a bug. severity-minor This label is used by an internal tool
Milestone

Comments

@QuinntyneBrown
Copy link

After importing MessagePackHubProtocol from @aspnet/signalr-protocol-msgpack inside of an Angular app using the Angular cli, the application will no longer run in the browser.

You will see the following exception in the console.

image

Steps to reproduce the behavior:

Clone and run the following app:
https://github.com/QuinntyneBrown/ng-signalr-protocol-msgpack-issue

or

  1. Create an angular app using the angular cli

  2. npm install @aspnet/signalr and @aspnet/signalr-protocol-msgpack

  3. In the app component, import HubConnectionBuilder from @aspnet/signalr

  4. In the app component, import MessagePackHubProtocolfrom @aspnet/signalr-protocol-msgpack

  5. In the app component, add a method called ngOnInit

  6. Inside the ngOnInit method, add the following code

    var connection = new HubConnectionBuilder()
    .withUrl("")
    .withHubProtocol(new MessagePackHubProtocol())
    .build();

  7. run the app with the console open, and you should see the error. The UI will be blank.

Expected behavior

You should see the standard angular cli default page.

@Eilon Eilon added the area-signalr Includes: SignalR clients and servers label Apr 23, 2019
@QuinntyneBrown
Copy link
Author

QuinntyneBrown commented Apr 24, 2019

I created the following duplicate issue with angular-cli.

angular/angular-cli#14253

I was asked to look at the following comment. angular/angular-cli#9827 (comment)

@BrennanConroy
Copy link
Member

BrennanConroy commented Apr 24, 2019

Take a look at aspnet/SignalR#2736 (comment) for a workaround.

triage we can investigate using a newer Buffer package that doesn't rely on global being defined.

@dcarr42
Copy link

dcarr42 commented Apr 24, 2019 via email

@mhosman
Copy link

mhosman commented Apr 29, 2019

Same error here!!!

@analogrelay analogrelay added this to the 3.0.0-preview7 milestone Apr 30, 2019
@analogrelay
Copy link
Contributor

We'll look and see if there's a good option here. We might end up dropping polyfills for some of these altogether so that each environment can bring an appropriate polyfill.

@analogrelay
Copy link
Contributor

We aren't going to be able to get to this in 3.0. Moving to the backlog.

@analogrelay analogrelay modified the milestones: 3.0.0-preview7, Backlog May 30, 2019
@mhosman
Copy link

mhosman commented May 31, 2019

So... You're gonna release a version that is not working with Angular?

@analogrelay
Copy link
Contributor

Is the linked workaround insufficient for you? If so we can bump the priority of this.

@mhosman
Copy link

mhosman commented May 31, 2019

Sorry, @anurse I didn't see that workaround!

@cyraid
Copy link

cyraid commented Dec 20, 2019

The workaround worked for me after I added the package "buffer" to package.json.
Edit: Gotta be something better than doing all this to make MessagePack work lol

@BrennanConroy BrennanConroy added affected-few This issue impacts only small number of customers bug This issue describes a behavior which is not expected - a bug. severity-minor This label is used by an internal tool labels Nov 6, 2020 — with ASP.NET Core Issue Ranking
@davidfowl
Copy link
Member

Does this repro with the latest changes? @BrennanConroy We changed the msg pack library so I wonder if the same issue exists.

@ghost
Copy link

ghost commented Apr 6, 2021

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@BrennanConroy
Copy link
Member

This might be fixed, I'll try it out and see if the issue is gone.

@BrennanConroy BrennanConroy self-assigned this Apr 6, 2021
@BrennanConroy
Copy link
Member

Doesn't look like the issue repros with the new messagepack library.

@philippseith
Copy link

philippseith commented Aug 27, 2021

@BrennanConroy I stlill got errors when using @microsoft/signalr-protocol-msgpack with angular 11.
Uncaught ReferenceError: global is not defined
and after fixing that
Uncaught ReferenceError: Buffer is not defined

I had to install the buffer package and add this to polyfill.js (from https://stackoverflow.com/a/64042896)

import * as Buffer from '../node_modules/buffer/index';
// Fix Uncaught ReferenceError: global is not defined
(window as any).global = window;
// Fix Uncaught ReferenceError: Buffer is not defined
(window as any).process = {};
(window as any).process = window;
(window as any).process.browser = true;
(window as any).process.version = '';
(window as any).process.versions = { node: false };
(window as any).global.Buffer = Buffer.Buffer;

@BrennanConroy
Copy link
Member

Are you using the 6.0 preview version of the package?

@philippseith
Copy link

5.0.9

@BrennanConroy
Copy link
Member

The 6.0+ version of the library doesn't have this issue.

5.0 and below will need to apply a workaround such as aspnet/SignalR#2736 (comment) or the one you listed.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affected-few This issue impacts only small number of customers area-signalr Includes: SignalR clients and servers bug This issue describes a behavior which is not expected - a bug. severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests

10 participants