Skip to content

🐛 ReferenceError: self is not defined --> I am using version "next": "^11.0.0", and I am getting this error in my link. #34202

@onurykaya

Description

@onurykaya

Describe the bug

!This situation occurs only in projects using next.js
I am using version "next": "^11.0.0", and I am getting this error in my link.
----> When I update the signalR version, I get the following error.

My new signalR version -> "@microsoft/signalr": "^5.0.7",
Old signalR version -> "@microsoft/signalr": "^3.1.9",

image

To Reproduce

To reproduce this issue, check to have the following code:

const mainHubConnection = new signalR.HubConnectionBuilder()
.withUrl(sportProgram, {
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets,
})
.configureLogging(signalR.LogLevel.Information)
.build();

let startSocket;

const handleSocketConnection = () => {
	if (eventData) {
		startSocket = () => {
			try {
				mainHubConnection.start()
					.then(() =>
						mainHubConnection.invoke("listen", programType, sportId)
							.catch((err) => {
								Sentry.captureException(err);
							}));
			} catch (err) {
				Sentry.captureException(err);
				setTimeout(startSocket, 5000);
			}
		};

		mainHubConnection.on("ReceivedSportProgramBySportId", (event) => {
			if (Object.keys(event).length > 0) {
				handleEventChange(event);
			}
		});

		if (sliderEvent) {
			startSocket();
		}
	}

Further technical details

  • ASP.NET Core version 5.0
  • Webstorm 2021.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.Status: No Recent Activityarea-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions