Implemented handling for RPC error returns
ci/woodpecker/tag/ociImageTag Pipeline was successful Details

This commit is contained in:
Natty 2024-12-24 02:49:39 +01:00
parent 96093d515e
commit b6bc717416
1 changed files with 13 additions and 8 deletions

View File

@ -64,21 +64,26 @@ async function getRpcClient(): Promise<Socket> {
return; return;
} }
const header = buf.readUInt8(); const header = String.fromCharCode(buf.readUInt8());
if (header != 77) { if (!["M", "F"].includes(header)) {
logger.error(`Invalid header: ${header}`); logger.error(`Invalid header: ${header}`);
return; return;
} }
const serial = buf.readBigUInt64BE(); const serial = buf.readBigUInt64BE();
const dataLen = buf.readUInt32BE(); let dataDecoded;
if (buf.remaining() < dataLen) { if (header === "M") {
buf.readOffset = 0; const dataLen = buf.readUInt32BE();
return; if (buf.remaining() < dataLen) {
buf.readOffset = 0;
return;
}
const data = buf.readBuffer(dataLen);
dataDecoded = decode(data);
} else {
dataDecoded = { success: false, data: "RPC returned failure" };
} }
const data = buf.readBuffer(dataLen);
const dataDecoded: any = decode(data);
// Move the rest of the data to the beginning of the buffer // Move the rest of the data to the beginning of the buffer
const rest = buf.readBuffer(); const rest = buf.readBuffer();