fix(plugin): address kubernetes fast upload review

This commit is contained in:
Dotta
2026-05-13 12:44:48 -05:00
committed by Chris Farhood
parent fcbbd50b60
commit 58d1b19206
5 changed files with 44 additions and 5 deletions
@@ -31,6 +31,7 @@ export interface FastUploadFlush {
export type FastUploadDecision =
| { action: "ack"; reason: string }
| { action: "flush"; flush: FastUploadFlush }
| { action: "error"; message: string }
| { action: "passthrough"; reason: string };
interface BufferedUpload {
@@ -42,6 +43,8 @@ interface BufferedUpload {
export class FastUploadInterceptor {
private readonly buffers = new Map<string, BufferedUpload>();
constructor(private readonly maxBufferBytes = MAX_BUFFER_BYTES) {}
decide(command: string): FastUploadDecision {
const initMatch = INIT_RE.exec(command);
if (initMatch) {
@@ -69,9 +72,12 @@ export class FastUploadInterceptor {
return { action: "passthrough", reason: "chunk without prior init" };
}
if (upload.totalBase64Chars + base64Chunk.length > (MAX_BUFFER_BYTES * 4) / 3) {
if (upload.totalBase64Chars + base64Chunk.length > (this.maxBufferBytes * 4) / 3) {
this.buffers.delete(tempPath);
return { action: "passthrough", reason: "buffer cap exceeded" };
return {
action: "error",
message: `Fast upload buffer cap exceeded for ${upload.targetPath}; retry the upload with a smaller payload.`,
};
}
upload.chunks.push(base64Chunk);