Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{
"$schema": "https://biomejs.dev/schemas/2.1.1/schema.json",

Check notice on line 2 in biome.json

View workflow job for this annotation

GitHub Actions / quality

deserialize

The configuration schema version does not match the CLI version 2.3.3
"files": {
"includes": [
"**/*.js",
"**/*.json",
"**/*.ts",
"!engine/artifacts",
"!engine/sdks",
"!engine/sdks/typescript/api-full",
"!engine/sdks/typescript/runner-protocol",
"!frontend",
Expand Down
13 changes: 11 additions & 2 deletions engine/sdks/typescript/runner/src/websocket-tunnel-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { logger } from "./log";

export class WebSocketTunnelAdapter {
#webSocketId: string;

Check warning on line 7 in engine/sdks/typescript/runner/src/websocket-tunnel-adapter.ts

View workflow job for this annotation

GitHub Actions / quality

lint/correctness/noUnusedPrivateClassMembers

This private class member is defined but never used.
#readyState: number = 0; // CONNECTING
#eventListeners: Map<string, Set<(event: any) => void>> = new Map();
#onopen: ((this: any, ev: any) => any) | null = null;
Expand All @@ -28,7 +28,11 @@
constructor(
webSocketId: string,
sendCallback: (data: ArrayBuffer | string, isBinary: boolean) => void,
closeCallback: (code?: number, reason?: string, retry?: boolean) => void,
closeCallback: (
code?: number,
reason?: string,
retry?: boolean,
) => void,
) {
this.#webSocketId = webSocketId;
this.#sendCallback = sendCallback;
Expand Down Expand Up @@ -223,7 +227,7 @@
addEventListener(
type: string,
listener: (event: any) => void,
options?: boolean | any,

Check warning on line 230 in engine/sdks/typescript/runner/src/websocket-tunnel-adapter.ts

View workflow job for this annotation

GitHub Actions / quality

lint/correctness/noUnusedFunctionParameters

This parameter is unused.
): void {
if (typeof listener === "function") {
let listeners = this.#eventListeners.get(type);
Expand Down Expand Up @@ -436,7 +440,12 @@
}

/// Returns false if the message was sent off.
_handleMessage(requestId: ArrayBuffer, data: string | Uint8Array, index: number, isBinary: boolean): boolean {
_handleMessage(
requestId: ArrayBuffer,
data: string | Uint8Array,
index: number,
isBinary: boolean,
): boolean {
if (this.#readyState !== 1) {
// OPEN
return true;
Expand Down Expand Up @@ -525,12 +534,12 @@
readonly CLOSED = 3;

// Additional methods for compatibility
ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void {

Check warning on line 537 in engine/sdks/typescript/runner/src/websocket-tunnel-adapter.ts

View workflow job for this annotation

GitHub Actions / quality

lint/correctness/noUnusedFunctionParameters

This parameter is unused.
// Not implemented for tunnel - could be added if needed
if (cb) cb(new Error("Ping not supported in tunnel adapter"));
}

pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void {

Check warning on line 542 in engine/sdks/typescript/runner/src/websocket-tunnel-adapter.ts

View workflow job for this annotation

GitHub Actions / quality

lint/correctness/noUnusedFunctionParameters

This parameter is unused.

Check warning on line 542 in engine/sdks/typescript/runner/src/websocket-tunnel-adapter.ts

View workflow job for this annotation

GitHub Actions / quality

lint/correctness/noUnusedFunctionParameters

This parameter is unused.
// Not implemented for tunnel - could be added if needed
if (cb) cb(new Error("Pong not supported in tunnel adapter"));
}
Expand Down
25 changes: 16 additions & 9 deletions engine/sdks/typescript/test-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const INTERNAL_SERVER_PORT = process.env.INTERNAL_SERVER_PORT
: 5051;
const RIVET_NAMESPACE = process.env.RIVET_NAMESPACE ?? "default";
const RIVET_RUNNER_NAME = process.env.RIVET_RUNNER_NAME ?? "test-runner";
const RIVET_RUNNER_KEY =
process.env.RIVET_RUNNER_KEY;
const RIVET_RUNNER_KEY = process.env.RIVET_RUNNER_KEY;
const RIVET_RUNNER_VERSION = process.env.RIVET_RUNNER_VERSION
? Number(process.env.RIVET_RUNNER_VERSION)
: 1;
Expand Down Expand Up @@ -106,8 +105,7 @@ if (AUTOSTART_SERVER) {

if (AUTOSTART_RUNNER) {
[runner, runnerStarted, runnerStopped] = await startRunner();
}
else await autoConfigureServerless();
} else await autoConfigureServerless();

async function autoConfigureServerless() {
const res = await fetch(
Expand Down Expand Up @@ -155,13 +153,14 @@ async function startRunner(): Promise<
token: RIVET_TOKEN,
namespace: RIVET_NAMESPACE,
runnerName: RIVET_RUNNER_NAME,
runnerKey: RIVET_RUNNER_KEY ?? `key-${Math.floor(Math.random() * 10000)}`,
runnerKey:
RIVET_RUNNER_KEY ?? `key-${Math.floor(Math.random() * 10000)}`,
totalSlots: RIVET_RUNNER_TOTAL_SLOTS,
prepopulateActorNames: {},
onConnected: () => {
runnerStarted.resolve(undefined);
},
onDisconnected: () => { },
onDisconnected: () => {},
onShutdown: () => {
runnerStopped.resolve(undefined);
},
Expand Down Expand Up @@ -227,9 +226,17 @@ async function startRunner(): Promise<
ws.send(`Echo: ${data}`);

// Ack
const websocketId = Buffer.from((event as any).rivetRequestId).toString("base64");
websocketLastMsgIndexes.set(websocketId, (event as any).rivetMessageIndex);
runner.sendWebsocketMessageAck((event as any).rivetRequestId, (event as any).rivetMessageIndex);
const websocketId = Buffer.from(
(event as any).rivetRequestId,
).toString("base64");
websocketLastMsgIndexes.set(
websocketId,
(event as any).rivetMessageIndex,
);
runner.sendWebsocketMessageAck(
(event as any).rivetRequestId,
(event as any).rivetMessageIndex,
);
});

ws.addEventListener("close", () => {
Expand Down
2 changes: 1 addition & 1 deletion engine/sdks/typescript/test-runner/src/log.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { inspect } from "node:util";
import {
type Level,
type LevelWithSilent,
type Logger,
pino,
stdTimeFunctions,
} from "pino";
import { inspect } from "util";

export type { Logger } from "pino";

Expand All @@ -25,13 +25,13 @@
return configuredLogLevel;
}

return (process.env["LOG_LEVEL"] || "warn")

Check notice on line 28 in engine/sdks/typescript/test-runner/src/log.ts

View workflow job for this annotation

GitHub Actions / quality

lint/complexity/useLiteralKeys

The computed expression can be simplified without the use of a string literal.
.toString()
.toLowerCase() as LevelWithSilent;
}

export function getIncludeTarget(): boolean {
return process.env["LOG_TARGET"] === "1";

Check notice on line 34 in engine/sdks/typescript/test-runner/src/log.ts

View workflow job for this annotation

GitHub Actions / quality

lint/complexity/useLiteralKeys

The computed expression can be simplified without the use of a string literal.
}

/**
Expand All @@ -47,7 +47,7 @@
const entries: any = {};

// Add timestamp if enabled
if (process.env["LOG_TIMESTAMP"] === "1" && o.time) {

Check notice on line 50 in engine/sdks/typescript/test-runner/src/log.ts

View workflow job for this annotation

GitHub Actions / quality

lint/complexity/useLiteralKeys

The computed expression can be simplified without the use of a string literal.
const date = typeof o.time === "number" ? new Date(o.time) : new Date();
entries.ts = date;
}
Expand Down Expand Up @@ -108,7 +108,7 @@
},
},
timestamp:
process.env["LOG_TIMESTAMP"] === "1"

Check notice on line 111 in engine/sdks/typescript/test-runner/src/log.ts

View workflow job for this annotation

GitHub Actions / quality

lint/complexity/useLiteralKeys

The computed expression can be simplified without the use of a string literal.
? stdTimeFunctions.epochTime
: false,
browser: {
Expand All @@ -135,7 +135,7 @@
};
const levelName = levelMap[level] || "info";
const time =
process.env["LOG_TIMESTAMP"] === "1"

Check notice on line 138 in engine/sdks/typescript/test-runner/src/log.ts

View workflow job for this annotation

GitHub Actions / quality

lint/complexity/useLiteralKeys

The computed expression can be simplified without the use of a string literal.
? Date.now()
: undefined;
// TODO: This can be simplified in logfmt.ts
Expand Down
Loading