Skip to content

Commit 5c9c38b

Browse files
committed
apps-engine timeout config
RocketChat/Rocket.Chat#33690
1 parent 3960933 commit 5c9c38b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

src/server/ProxiedApp.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ export class ProxiedApp {
5454
let options;
5555

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

6161
try {
6262
return await this.appRuntime.sendRequest({ method: `app:${method}`, params: args }, options);

src/server/runtime/deno/AppsEngineDenoRuntime.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ const COMMAND_PONG = '_zPONG';
5353

5454
export const JSONRPC_METHOD_NOT_FOUND = -32601;
5555

56+
export function getRuntimeTimeout() {
57+
const defaultTimeout = 30000;
58+
const envValue = isFinite(process.env.APPS_ENGINE_RUNTIME_TIMEOUT as any) ? Number(process.env.APPS_ENGINE_RUNTIME_TIMEOUT) : defaultTimeout;
59+
60+
if (envValue < 0) {
61+
console.log('Environment variable APPS_ENGINE_RUNTIME_TIMEOUT has a negative value, ignoring...');
62+
return defaultTimeout;
63+
}
64+
65+
return envValue;
66+
}
67+
5668
export function isValidOrigin(accessor: string): accessor is typeof ALLOWED_ACCESSOR_METHODS[number] {
5769
return ALLOWED_ACCESSOR_METHODS.includes(accessor as any);
5870
}
@@ -88,7 +100,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
88100
private readonly debug: debug.Debugger;
89101

90102
private readonly options = {
91-
timeout: 10000,
103+
timeout: getRuntimeTimeout(),
92104
};
93105

94106
private readonly accessors: AppAccessorManager;

0 commit comments

Comments
 (0)