KSE0475
KSE0475

Reputation: 31

(Angular 18) Getting "ChunkLoadError" when using signalr with ngx-build plus

Environments

The Error

Error: ChunkLoadError: Loading chunk <chunk-name> failed.  
(missing: <URL>)

Click here for Error image

Which lines are causing the issue?

After thoroughly investigated the issue and identified the root cause. The following lines of code were the primary contributors to the problem:

import { HubConnectionBuilder } from '@microsoft/signalr';

this._hubConnection = new HubConnectionBuilder()
  .withUrl(this.apiUrl, {})
  .withAutomaticReconnect([0, 1000, 5000, null])
  .build();

What did i try?

When these lines are commented out, the program runs without errors. However, these lines are essential for establishing a connection with SignalR, so they cannot be omitted. In few other similar issues that were closed in Github, it was recommended to use signalr version 8 to fix this issue. We are using v8 but still this issue is not fixed.

Interestingly, this works perfectly with the @angular-devkit/build-angular builder but encounters issues when used with ngx-build-plus. At this point, the exact reason for the incompatibility is unclear. We will need further analysis or expert guidance to resolve this while retaining SignalR functionality.

Upvotes: 2

Views: 65

Answers (1)

KSE0475
KSE0475

Reputation: 31

This error is now fixed!

Use this exact version @microsoft/signalr:"8.0.0" instead of any other versions and this error will be fixed :)

Upvotes: 1

Related Questions