Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.
Merged
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
2 changes: 2 additions & 0 deletions deno-runtime/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Handlers = {
slashcommand: typeof slashcommandHandler;
videoconference: typeof videoConferenceHandler;
scheduler: typeof handleScheduler;
ping: (method: string, params: unknown) => 'pong';
};

async function requestRouter({ type, payload }: Messenger.JsonRpcRequest): Promise<void> {
Expand All @@ -37,6 +38,7 @@ async function requestRouter({ type, payload }: Messenger.JsonRpcRequest): Promi
slashcommand: slashcommandHandler,
videoconference: videoConferenceHandler,
scheduler: handleScheduler,
ping: (_method, _params) => 'pong',
};

// We're not handling notifications at the moment
Expand Down
26 changes: 26 additions & 0 deletions src/server/runtime/deno/AppsEngineDenoRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
this.deno = child_process.spawn(denoExePath, options);

this.setupListeners();
this.startPing();

queueMicrotask(() => {
if (this.deno.exitCode !== null) {
this.state = 'invalid';
this.debug('Deno subprocess exited with code %d, signal %s', this.deno.exitCode, this.deno.signalCode);
}
});
} catch (e) {
this.state = 'invalid';
console.error('Failed to start Deno subprocess', e);
Expand All @@ -137,6 +145,24 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
this.runtimeManager = manager.getRuntime();
}

private startPing() {
const ping = () => {
const start = Date.now();
this.sendRequest({ method: 'ping', params: [] })
.then((result) => {
if (result !== 'pong') {
this.debug(`Expected 'pong', got %s (%d ms)`, result, Date.now() - start);
}
})
.catch((reason: unknown) => {
this.debug('Ping failed: %s (%d ms)', reason, Date.now() - start);
});
};

ping();
setInterval(ping, 5000);
}

// Debug purposes, could be deleted later
emit(eventName: string | symbol, ...args: any[]): boolean {
const hadListeners = super.emit(eventName, ...args);
Expand Down