Don't send streaming request if generation was aborted before the streaming processor creation

57175b422969e878d378c7c40dd7bf49b6340c37

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +4 -0Showing whitespace changes
public/script.js+4 -0
@@ -5020,6 +5020,10 @@ async function sendGenerationRequest(type, data) {
50205020 * @returns {Promise<any>} Streaming generator
50215021 */
50225022async function sendStreamingRequest(type, data) {
5023+ if (abortController?.signal?.aborted) {
5024+ throw new Error('Generation was aborted.');
5025+ }
5026+
50235027 switch (main_api) {
50245028 case 'openai':
50255029 return await sendOpenAIRequest(type, data.prompt, streamingProcessor.abortController.signal);