Skip to content

Commit 8c948d3

Browse files
authored
Surface error for missing key or url. (#6179)
1 parent ca31c0a commit 8c948d3

3 files changed

Lines changed: 67 additions & 5 deletions

File tree

app/i18n/en-US/streaming.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
"Missing required oauth scope": "Missing required oauth scope",
9191
"Failed to fetch platform settings": "Failed to fetch platform settings",
9292
"Failed to update platform settings": "Failed to update platform settings",
93+
"Stream key missing. Relogin or remerge to refresh it.": "Stream key missing. Relogin or remerge to refresh it.",
94+
"Server url missing. Relogin or remerge to refresh it.": "Server url missing. Relogin or remerge to refresh it.",
9395
"The Multistream server is temporarily unavailable": "The Multistream server is temporarily unavailable",
9496
"Failed to configure the Multistream server": "Failed to configure the Multistream server",
9597
"disable Enhanced Broadcasting for Twitch and try again": "disable Enhanced Broadcasting for Twitch and try again",

app/services/streaming/stream-error.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ export const errorTypes = {
3636
return $t('Failed to update platform settings');
3737
},
3838
},
39+
STREAM_KEY_MISSING: {
40+
get message() {
41+
return $t('Stream key missing. Relogin or remerge to refresh it.');
42+
},
43+
},
44+
STREAM_SERVER_MISSING: {
45+
get message() {
46+
return $t('Server url missing. Relogin or remerge to refresh it.');
47+
},
48+
},
3949
RESTREAM_DISABLED: {
4050
get message() {
4151
return $t('The Multistream server is temporarily unavailable');

app/services/streaming/streaming.ts

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -783,10 +783,16 @@ export class StreamingService
783783
} catch (e: unknown) {
784784
console.error('Error starting video transmission: ', e);
785785

786-
const failureType =
787-
e && (e as any).message && (e as any).message.includes('encoder')
788-
? 'INVALID_ENCODER'
789-
: 'UNKNOWN_ERROR';
786+
// A blank stream key or server url fails here as a bare `UNKNOWN_ERROR`, which tells the
787+
// user nothing. Name the missing field instead when that is what went wrong.
788+
const missingSetting = this.getMissingStreamSetting();
789+
790+
let failureType: TStreamErrorType = 'UNKNOWN_ERROR';
791+
if (e && (e as any).message && (e as any).message.includes('encoder')) {
792+
failureType = 'INVALID_ENCODER';
793+
} else if (missingSetting) {
794+
failureType = missingSetting === 'key' ? 'STREAM_KEY_MISSING' : 'STREAM_SERVER_MISSING';
795+
}
790796

791797
const errorType = this.handleTypedStreamError(
792798
e,
@@ -4397,6 +4403,37 @@ export class StreamingService
43974403
private streamErrorUserMessage = '';
43984404
private streamErrorReportMessage = '';
43994405

4406+
/**
4407+
* Whether an output failed because its stream settings were incomplete
4408+
* @remark OBS signals returns a generic `InvalidStream`/`BadPath` error when the stream failed to
4409+
* start due to misconfigured settings. Check for a missing key or url to surface that specific error,
4410+
* which is more helpful for the user.
4411+
* @param context - The output context that failed, as reported on the signal
4412+
* @returns The missing field, or `null` when the settings are complete
4413+
*/
4414+
private getMissingStreamSetting(context?: string): 'key' | 'server' | null {
4415+
// The enhanced broadcasting instance streams Twitch, so it uses Twitch's display
4416+
let display: TDisplayType = 'horizontal';
4417+
if (context === 'vertical') {
4418+
display = 'vertical';
4419+
} else if (context === 'enhancedBroadcasting') {
4420+
display = this.views.getPlatformDisplayType('twitch');
4421+
}
4422+
4423+
const settings =
4424+
display === 'vertical'
4425+
? this.settingsService.views.values.StreamSecond
4426+
: this.settingsService.views.values.Stream;
4427+
4428+
if (!settings.key) return 'key';
4429+
4430+
// `rtmp_common` resolves the ingest from the service, so an empty server is only a problem
4431+
// for a custom ingest
4432+
if (!settings.server && settings.streamType !== 'rtmp_common') return 'server';
4433+
4434+
return null;
4435+
}
4436+
44004437
private handleOBSOutputError(info: IOBSOutputSignalInfo, platform?: string) {
44014438
console.log('OBS Output Error signal: ', info);
44024439

@@ -4429,7 +4466,20 @@ export class StreamingService
44294466
let showNativeErrorMessage = false;
44304467
let diagReportMessage = this.streamErrorUserMessage;
44314468

4432-
if (info.code === EOutputCode.BadPath) {
4469+
// Surface a more specific error for a missing stream key or server url
4470+
const missingSetting =
4471+
info.code === EOutputCode.InvalidStream || info.code === EOutputCode.BadPath
4472+
? this.getMissingStreamSetting(info.service)
4473+
: null;
4474+
4475+
if (missingSetting) {
4476+
const messages = formatStreamErrorMessage(
4477+
missingSetting === 'key' ? 'STREAM_KEY_MISSING' : 'STREAM_SERVER_MISSING',
4478+
);
4479+
4480+
errorText = messages.user;
4481+
diagReportMessage = messages.report;
4482+
} else if (info.code === EOutputCode.BadPath) {
44334483
errorText = $t(
44344484
'Invalid Path or Connection URL. Please check your settings to confirm that they are valid.',
44354485
);

0 commit comments

Comments
 (0)