maybe shows clearer AWS ValidationExceptions when users have bad prefills
This commit is contained in:
@@ -74,8 +74,15 @@ export class SSEStreamAdapter extends Transform {
|
|||||||
throw new RetryableError("AWS request throttled mid-stream");
|
throw new RetryableError("AWS request throttled mid-stream");
|
||||||
default:
|
default:
|
||||||
this.log.error({ message, type }, "Received bad AWS stream event");
|
this.log.error({ message, type }, "Received bad AWS stream event");
|
||||||
|
let text;
|
||||||
|
try {
|
||||||
|
const { bytes } = JSON.parse(bodyStr);
|
||||||
|
text = Buffer.from(bytes, "base64").toString("utf8");
|
||||||
|
} catch (error) {
|
||||||
|
text = bodyStr;
|
||||||
|
}
|
||||||
const error: any = new Error(`Got mysterious error chunk: ${type}`);
|
const error: any = new Error(`Got mysterious error chunk: ${type}`);
|
||||||
error.lastEvent = message;
|
error.lastEvent = text;
|
||||||
this.emit("error", error);
|
this.emit("error", error);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user