on();
                             if (jsonData.code !== 200 && jsonData.msg) { // Check for backend's specific error format
                                 throw new Error(jsonData.msg);
                              } else if (jsonData.code !== 200) {
                                 throw new Error('Received an unexpected JSON error from the summary API.');
                              }
                             // Handle unexpected JSON success response? Unlikely for a stream endpoint.
           