Skip to content

Commit de5b694

Browse files
committed
Add env UNITY_REQUEST_TIMEOUT to allow setting the timeout in seconds for requests to the Unity Editor Bridge.
1 parent 79153f4 commit de5b694

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Server/build/unity/mcpUnity.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class McpUnity {
88
port;
99
ws = null;
1010
pendingRequests = new Map();
11-
REQUEST_TIMEOUT = 10000;
11+
REQUEST_TIMEOUT;
1212
retryDelay = 1000;
1313
constructor(logger) {
1414
this.logger = logger;
@@ -19,6 +19,10 @@ export class McpUnity {
1919
const envPort = process.env.UNITY_PORT || envRegistry;
2020
this.port = envPort ? parseInt(envPort, 10) : 8090;
2121
this.logger.info(`Using port: ${this.port} for Unity WebSocket connection`);
22+
// Initialize timeout from environment variable (in seconds; it is the same as Cline) or use default (10 seconds)
23+
const envTimeout = process.env.UNITY_REQUEST_TIMEOUT;
24+
this.REQUEST_TIMEOUT = envTimeout ? parseInt(envTimeout, 10) * 1000 : 10000;
25+
this.logger.info(`Using request timeout: ${this.REQUEST_TIMEOUT / 1000} seconds`);
2226
}
2327
/**
2428
* Start the Unity connection

Server/src/unity/mcpUnity.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class McpUnity {
3333
private port: number;
3434
private ws: WebSocket | null = null;
3535
private pendingRequests: Map<string, PendingRequest> = new Map<string, PendingRequest>();
36-
private readonly REQUEST_TIMEOUT = 10000;
36+
private readonly REQUEST_TIMEOUT: number;
3737
private retryDelay = 1000;
3838

3939
constructor(logger: Logger) {
@@ -46,8 +46,12 @@ export class McpUnity {
4646

4747
const envPort = process.env.UNITY_PORT || envRegistry;
4848
this.port = envPort ? parseInt(envPort, 10) : 8090;
49-
5049
this.logger.info(`Using port: ${this.port} for Unity WebSocket connection`);
50+
51+
// Initialize timeout from environment variable (in seconds; it is the same as Cline) or use default (10 seconds)
52+
const envTimeout = process.env.UNITY_REQUEST_TIMEOUT;
53+
this.REQUEST_TIMEOUT = envTimeout ? parseInt(envTimeout, 10) * 1000 : 10000;
54+
this.logger.info(`Using request timeout: ${this.REQUEST_TIMEOUT / 1000} seconds`);
5155
}
5256

5357
/**

0 commit comments

Comments
 (0)