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

Update xhr-loader.ts #6359

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/xhr-loader.ts
Expand Up @@ -250,7 +250,7 @@ class XhrLoader implements Loader<LoaderContext> {
this.retry(retryConfig);
} else {
logger.error(`${status} while loading ${context.url}`);
this.callbacks!.onError(
this.callbacks.onError(
Copy link
Collaborator

@robwalch robwalch Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ! is a TypeScript non-null assertion operator. It is not runtime code. This code must be converted from TS to JS before it is run.

this.callbacks! appears twice in this file. If we decide to remove the non-null assertions, we must remove both, and add null checks before them, like } else if (this.callbacks) { or if (!this.callbacks) { return; } for example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is Throwing Error as OnError on xhrrequest

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using hls as multipalyer and controlling all through a common controller

Copy link
Collaborator

@robwalch robwalch May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to remove the non-null assertions, you must remove both, and add null checks before each of them.

{ code: status, text: xhr.statusText },
context,
xhr,
Expand Down