fix rebuild for serverless

This commit is contained in:
Fredrik Jensen 2025-12-06 15:25:21 +01:00
parent 76fbc07343
commit 8f439f8ab7
3 changed files with 11 additions and 5 deletions

2
package-lock.json generated
View File

@ -4004,7 +4004,7 @@
}, },
"packages/library": { "packages/library": {
"name": "mcp-ui-kit", "name": "mcp-ui-kit",
"version": "1.0.0", "version": "1.0.2",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@mcp-ui/server": "^5.15.0", "@mcp-ui/server": "^5.15.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "mcp-ui-kit", "name": "mcp-ui-kit",
"version": "1.0.0", "version": "1.0.2",
"description": "MCP UI Kit - Create rich UI components for MCP servers", "description": "MCP UI Kit - Create rich UI components for MCP servers",
"type": "module", "type": "module",
"main": "./dist/server/index.cjs", "main": "./dist/server/index.cjs",

View File

@ -32,10 +32,16 @@ export async function bundleComponent(entryPath: string): Promise<string> {
try { try {
result = await runBuild(entryPath); result = await runBuild(entryPath);
} catch (error) { } catch (error) {
// Handle "The service was stopped" error in serverless environments (Vercel, Lambda, etc.) // Handle esbuild service errors in serverless environments (Vercel, Lambda, etc.)
// This happens when the serverless runtime freezes/stops the esbuild subprocess. // This happens when the serverless runtime freezes/stops the esbuild subprocess.
// Error messages vary: "service was stopped", "service is no longer running", etc.
// esbuild automatically restarts its service on the next call, so we just retry. // esbuild automatically restarts its service on the next call, so we just retry.
if (error instanceof Error && error.message.includes('service was stopped')) { const isServiceError = error instanceof Error && (
error.message.includes('service was stopped') ||
error.message.includes('service is no longer running') ||
error.message.includes('The service')
);
if (isServiceError) {
result = await runBuild(entryPath); result = await runBuild(entryPath);
} else { } else {
throw error; throw error;