Implemented handling for RPC error returns
ci/woodpecker/tag/ociImageTag Pipeline was successful
Details
ci/woodpecker/tag/ociImageTag Pipeline was successful
Details
This commit is contained in:
parent
96093d515e
commit
b6bc717416
|
@ -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();
|
||||
|
||||
const dataLen = buf.readUInt32BE();
|
||||
if (buf.remaining() < dataLen) {
|
||||
buf.readOffset = 0;
|
||||
return;
|
||||
let dataDecoded;
|
||||
if (header === "M") {
|
||||
const dataLen = buf.readUInt32BE();
|
||||
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
|
||||
const rest = buf.readBuffer();
|
||||
|
|
Loading…
Reference in New Issue