Skip to content

Commit 475e7e7

Browse files
committed
Fix reconnection
1 parent cd0b2b0 commit 475e7e7

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Boot.Server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async function initializeConnection(options: BlazorOptions, logger: Logger, circ
9696
connection.on('JS.BeginInvokeJS', DotNet.jsCallDispatcher.beginInvokeJSFromDotNet);
9797
connection.on('JS.EndInvokeDotNet', (args: string) => DotNet.jsCallDispatcher.endInvokeDotNetFromJS(...(JSON.parse(args) as [string, boolean, unknown])));
9898

99-
const renderQueue = new RenderQueue(/* renderer ID unused with remote renderer */ 0, logger);
99+
const renderQueue = RenderQueue.getOrCreate(logger);
100100
connection.on('JS.RenderBatch', (batchId: number, batchData: Uint8Array) => {
101101
logger.log(LogLevel.Debug, `Received render batch with id ${batchId} and ${batchData.byteLength} bytes.`);
102102
renderQueue.processBatch(batchId, batchData, connection);

src/Components/Web.JS/src/Platform/Circuits/RenderQueue.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { Logger, LogLevel } from '../Logging/Logger';
44
import { HubConnection } from '@aspnet/signalr';
55

66
export class RenderQueue {
7+
private static instance: RenderQueue;
8+
79
private nextBatchId = 2;
810

911
private fatalError?: string;
@@ -17,6 +19,14 @@ export class RenderQueue {
1719
this.logger = logger;
1820
}
1921

22+
public static getOrCreate(logger: Logger): RenderQueue {
23+
if (!RenderQueue.instance) {
24+
RenderQueue.instance = new RenderQueue(0, logger);
25+
}
26+
27+
return this.instance;
28+
}
29+
2030
public async processBatch(receivedBatchId: number, batchData: Uint8Array, connection: HubConnection): Promise<void> {
2131
if (receivedBatchId < this.nextBatchId) {
2232
// SignalR delivers messages in order, but it does not guarantee that the message gets delivered.

src/Components/test/E2ETest/ServerExecutionTests/ComponentHubReliabilityTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Ignitor;
1212
using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures;
1313
using Microsoft.AspNetCore.Components.RenderTree;
14+
using Microsoft.AspNetCore.Components.Web;
1415
using Microsoft.AspNetCore.SignalR.Client;
1516
using Microsoft.Extensions.DependencyInjection;
1617
using Microsoft.Extensions.Logging;

0 commit comments

Comments
 (0)