Skip to content

Commit 46fff53

Browse files
authored
fix: [FFM-12499]: fix uncaught exception when getting flags/segments fails on SSE event (#126)
* fix: [FFM-12499]: fix uncaught exception when getting flags/segments fails on SSE event * run npx prettier to format code
1 parent c09e4ab commit 46fff53

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/streaming.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {
1111
debugStreamEventReceived,
1212
infoStreamStopped,
1313
warnStreamDisconnectedWithRetry,
14-
resetDisconnectCounter, restartDisconnectCounter
15-
} from "./sdk_codes";
14+
resetDisconnectCounter,
15+
restartDisconnectCounter,
16+
} from './sdk_codes';
1617

1718
type FetchFunction = (
1819
identifier: string,
@@ -188,8 +189,8 @@ export class StreamProcessor {
188189
.on('timeout', () => {
189190
onFailed(
190191
'SSE request timed out after ' +
191-
StreamProcessor.SSE_TIMEOUT_MS +
192-
'ms',
192+
StreamProcessor.SSE_TIMEOUT_MS +
193+
'ms',
193194
);
194195
})
195196
.setTimeout(StreamProcessor.SSE_TIMEOUT_MS);
@@ -217,13 +218,25 @@ export class StreamProcessor {
217218
this.api.getFeatureConfigByIdentifier.bind(this.api),
218219
this.repository.setFlag.bind(this.repository),
219220
this.repository.deleteFlag.bind(this.repository),
221+
).then(
222+
(_) => this.log.info('>>SSE Got flag for:', msg.identifier),
223+
(e) =>
224+
this.log.error('>>SSE Failed to get flag for:', msg.identifier, e),
220225
);
221226
} else if (msg.domain === 'target-segment') {
222227
this.msgProcessor(
223228
msg,
224229
this.api.getSegmentByIdentifier.bind(this.api),
225230
this.repository.setSegment.bind(this.repository),
226231
this.repository.deleteSegment.bind(this.repository),
232+
).then(
233+
(_) => this.log.info('SSE Got target-segment for:', msg.identifier),
234+
(e) =>
235+
this.log.error(
236+
'>>SSE Failed to get target-segment for:',
237+
msg.identifier,
238+
e,
239+
),
227240
);
228241
}
229242
}
@@ -275,7 +288,7 @@ export class StreamProcessor {
275288
this.readyState = StreamProcessor.CLOSED;
276289
this.log.info('Closing StreamProcessor');
277290

278-
resetDisconnectCounter()
291+
resetDisconnectCounter();
279292
this.request.destroy();
280293
this.request = undefined;
281294

0 commit comments

Comments
 (0)