angularsignalr-client

Right-hand side of 'instanceof' is not callable in SignalR 1.1.2


After upgrading @aspnet/signalr from 1.0.0 to 1.1.2 , I get the following error when I call startConnection() :

Error parsing handshake response: TypeError: Right-hand side of 'instanceof' is not callable

this is my service :

@Injectable()
export class SignalRService {

  careworkerTrckInfo = new EventEmitter<GeoLocationCareWorkerTrackSignalR>();
  connectionEstablished = new EventEmitter<Boolean>();

  private connectionIsEstablished = false;
  private serverTimeoutInMilliseconds = 50000; // 50 Second

  private _hubConnection: HubConnection;

constructor(
    @Inject(APP_CONFIG) private appConfig: IAppConfig) {
    this.createConnection();
    this.startConnection();
}

private createConnection() {
    const url = `${this.appConfig.apiEndpoint}/notifications`;
    this._hubConnection = new HubConnectionBuilder()
        .withUrl(url)
        .build();
    this._hubConnection.serverTimeoutInMilliseconds = this.serverTimeoutInMilliseconds;
}

private startConnection() {
    this._hubConnection
    .start()
    .then(() => {
        this.connectionIsEstablished = true;
        this.connectionEstablished.emit(true);
    })
    .catch(err => {
        console.log('Error while establishing connection.');
    });
}}

it used to work!


Solution

  • The following code is in my index.html :

    <script>
        var global = global || window;
        // var Buffer = Buffer || []; --> remove or comment this line
        var process = process || {
            env: {
                DEBUG: undefined
            },
            version: []
        };
    </script>
    

    I removed (commented) Buffer, it solved my problem.