Skip to content

Commit 927db9b

Browse files
committed
race condition in cleanup + better JSDoc in config + dockerfile formatting
1 parent 68b2ebf commit 927db9b

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
FROM node:lts-alpine AS builder
33
WORKDIR /app
44

5-
# Copy package and configuration
6-
COPY package.json pnpm-lock.yaml tsconfig.json ./
5+
# Copy package files first for dependency caching
6+
COPY package.json pnpm-lock.yaml ./
7+
RUN corepack enable && pnpm install --frozen-lockfile
78

8-
# Copy source code
9+
# Copy configuration and source code
10+
COPY tsconfig.json ./
911
COPY src ./src
10-
11-
# Copy config files
1212
COPY config.d.ts index.d.ts ./
1313

14-
# Install dependencies and build
15-
RUN corepack enable && pnpm install --frozen-lockfile && pnpm build
14+
# Build the application
15+
RUN pnpm build
1616

1717
# ----- Production Stage -----
1818
FROM node:lts-alpine
1919
WORKDIR /app
2020

21-
# Copy package.json and install production dependencies
21+
# Copy package files and install production dependencies
2222
COPY package.json pnpm-lock.yaml ./
2323
RUN corepack enable && pnpm install --prod --frozen-lockfile --ignore-scripts
2424

config.d.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export type Config = {
4040
persist?: boolean;
4141
};
4242
/**
43-
*
43+
* The viewport of the browser
44+
* @default { browserWidth: 1024, browserHeight: 768 }
4445
*/
4546
viewPort?: {
4647
/**
@@ -58,16 +59,30 @@ export type Config = {
5859
*/
5960
cookies?: Cookie[];
6061
/**
61-
* Whether or not to port to a server
62+
* Server configuration for MCP transport layer
63+
*
64+
* Controls how the MCP server binds and listens for connections.
65+
* When port is specified, the server will start an SHTTP transport.
66+
* When both port and host are undefined, the server uses stdio transport.
6267
*
68+
* Security considerations:
69+
* - Use localhost (default) for local development
70+
* - Use 0.0.0.0 only when you need external access and have proper security measures
71+
* - Consider firewall rules and network security when exposing the server
6372
*/
6473
server?: {
6574
/**
6675
* The port to listen on for SHTTP or MCP transport.
76+
* If undefined, uses stdio transport instead of HTTP.
77+
*
78+
* @example 3000
6779
*/
6880
port?: number;
6981
/**
70-
* The host to bind the server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.
82+
* The host to bind the server to.
83+
*
84+
* @default "localhost" - Only accepts local connections
85+
* @example "0.0.0.0" - Accepts connections from any interface (use with caution)
7186
*/
7287
host?: string;
7388
};

src/program.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ program
8585
function setupExitWatchdog(serverList: ServerList) {
8686
const handleExit = async () => {
8787
setTimeout(() => process.exit(0), 15000);
88-
await stagehandStore.removeAll();
89-
await serverList.closeAll();
88+
try {
89+
await Promise.all([stagehandStore.removeAll(), serverList.closeAll()]);
90+
} catch (error) {
91+
console.error("Error during cleanup:", error);
92+
}
9093
process.exit(0);
9194
};
9295

0 commit comments

Comments
 (0)