Skip to content

Commit

Permalink
apps-engine timeout config
Browse files Browse the repository at this point in the history
  • Loading branch information
d-gubert committed Dec 6, 2024
1 parent 812a6ed commit 0976d8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/server/ProxiedApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ export class ProxiedApp {
let options;

// Pre events need to be fast as they block the user
if (method.startsWith('checkPre') || method.startsWith('executePre')) {
options = { timeout: 1000 };
}
// if (method.startsWith('checkPre') || method.startsWith('executePre')) {
// options = { timeout: 1000 };
// }

try {
return await this.appRuntime.sendRequest({ method: `app:${method}`, params: args }, options);
Expand Down
14 changes: 13 additions & 1 deletion src/server/runtime/deno/AppsEngineDenoRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ const COMMAND_PONG = '_zPONG';

export const JSONRPC_METHOD_NOT_FOUND = -32601;

export function getRuntimeTimeout() {
const defaultTimeout = 30000;
const envValue = isFinite(process.env.APPS_ENGINE_RUNTIME_TIMEOUT as any) ? Number(process.env.APPS_ENGINE_RUNTIME_TIMEOUT) : defaultTimeout;

if (envValue < 0) {
console.log('Environment variable APPS_ENGINE_RUNTIME_TIMEOUT has a negative value, ignoring...');
return defaultTimeout;
}

return envValue;
}

export function isValidOrigin(accessor: string): accessor is typeof ALLOWED_ACCESSOR_METHODS[number] {
return ALLOWED_ACCESSOR_METHODS.includes(accessor as any);
}
Expand Down Expand Up @@ -88,7 +100,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
private readonly debug: debug.Debugger;

private readonly options = {
timeout: 10000,
timeout: getRuntimeTimeout(),
};

private readonly accessors: AppAccessorManager;
Expand Down

0 comments on commit 0976d8f

Please sign in to comment.