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