Compare commits

...

2 Commits

Author SHA1 Message Date
Natty 58266bcb7f
RPC fixes
ci/woodpecker/tag/ociImageTag Pipeline was successful Details
2024-11-15 23:12:21 +01:00
Natty 53149858e9
Updated Alpine in Dockerfile
ci/woodpecker/tag/ociImageTag Pipeline was successful Details
2024-11-15 21:12:13 +01:00
3 changed files with 9 additions and 8 deletions

View File

@ -1,5 +1,5 @@
## Install dev and compilation dependencies, build files
FROM alpine:3.18 as build
FROM alpine:3.20 as build
WORKDIR /calckey
# Install compilation dependencies
@ -20,7 +20,7 @@ RUN env NODE_ENV=production sh -c "pnpm run build"
RUN pnpm i --prod --frozen-lockfile
## Runtime container
FROM alpine:3.18
FROM alpine:3.20
WORKDIR /calckey
# Install runtime dependencies

View File

@ -6,7 +6,7 @@
"type": "git",
"url": "https://git.astolfo.cool/natty/calckey"
},
"packageManager": "pnpm@8.6.3+sha512.d18e277ae8072091046bccbca0931f77dc3080791cd6122ae890bf504125d8af76b37fb33da287dba9fbbb6da6ebb13e314e9fa4a464c7effe3d8599cebe7243",
"packageManager": "pnpm@9.1.2",
"private": true,
"scripts": {
"rebuild": "pnpm run clean && pnpm node ./scripts/build-greet.js && pnpm -r run build",

View File

@ -13,7 +13,7 @@ let serial: bigint = BigInt(0);
const logger = new Logger("RpcLog");
function getRpcClient(): Socket {
if (client) {
if (client != null) {
return client;
}
@ -85,6 +85,9 @@ function getRpcClient(): Socket {
}
async function rpcCall<D, T>(method: string, data: D): Promise<T> {
const currentSerial = serial;
serial = serial + BigInt(1);
const header = new Uint8Array([77]);
const textEncoder = new TextEncoder();
const methodBuf = textEncoder.encode(method);
@ -99,7 +102,7 @@ async function rpcCall<D, T>(method: string, data: D): Promise<T> {
packetBuf.set(dataBuf, header.length + serialLength + sizeLength + methodBuf.length + sizeLength);
const packetDataView = new DataView(packetBuf.buffer);
packetDataView.setBigUint64(header.length, serial);
packetDataView.setBigUint64(header.length, currentSerial);
packetDataView.setUint32(header.length + serialLength, methodBuf.length);
packetDataView.setUint32(header.length + serialLength + sizeLength + methodBuf.length, dataBuf.length);
@ -107,13 +110,11 @@ async function rpcCall<D, T>(method: string, data: D): Promise<T> {
client.write(packetBuf);
const fut = new Promise((resolve, reject) => {
client.once(`mag-data:${serial}`, resolve);
client.once(`mag-data:${currentSerial}`, resolve);
client.once("close", reject);
client.once("error", reject);
});
serial++;
const result = await fut as { success: false, data: any } | { success: true, data: T };
if (!result.success) {