File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
extension/js/common/api/shared Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -237,12 +237,21 @@ export class Api {
237237 return { response, pipe : Value . noop } ; // original response
238238 }
239239 } ;
240+
240241 if ( resFmt === 'text' ) {
241242 const transformed = transformResponseWithProgressAndTimeout ( ) ;
242243 return ( await Promise . all ( [ transformed . response . text ( ) , transformed . pipe ( ) ] ) ) [ 0 ] as FetchResult < T , RT > ;
243244 } else if ( resFmt === 'json' ) {
244- const transformed = transformResponseWithProgressAndTimeout ( ) ;
245- return ( await Promise . all ( [ transformed . response . json ( ) , transformed . pipe ( ) ] ) ) [ 0 ] as FetchResult < T , RT > ;
245+ try {
246+ const transformed = transformResponseWithProgressAndTimeout ( ) ;
247+ return ( await Promise . all ( [ transformed . response . json ( ) , transformed . pipe ( ) ] ) ) [ 0 ] as FetchResult < T , RT > ;
248+ } catch ( e ) {
249+ // handle empty response https://github.com/FlowCrypt/flowcrypt-browser/issues/5601
250+ if ( e instanceof SyntaxError && e . message === 'Unexpected end of JSON input' ) {
251+ return undefined as FetchResult < T , RT > ;
252+ }
253+ throw e ;
254+ }
246255 } else {
247256 return undefined as FetchResult < T , RT > ;
248257 }
You can’t perform that action at this time.
0 commit comments