Skip to content

Commit 5d13533

Browse files
committed
refactor: fix race condition in serve command by awaiting plugin registration calls
1 parent 2cb6c93 commit 5d13533

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@objectstack/plugin-hono-server": patch
3+
"@objectstack/objectql": patch
4+
"@objectstack/cli": patch
5+
---
6+
7+
refactor: fix service registration compatibility and improve logging
8+
- plugin-hono-server: register 'http.server' service alias to match core requirements
9+
- plugin-hono-server: fix console log to show the actual bound port instead of configured port
10+
- plugin-hono-server: reduce log verbosity (moved non-essential logs to debug level)
11+
- objectql: automatically register 'metadata', 'data', 'and 'auth' services during initialization to satisfy kernel contracts
12+
- cli: fix race condition in `serve` command by awaiting plugin registration calls (`kernel.use`)

packages/cli/src/commands/serve.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export const serveCommand = new Command('serve')
112112
try {
113113
console.log(chalk.dim(` Auto-injecting ObjectQL Engine...`));
114114
const { ObjectQLPlugin } = await import('@objectstack/objectql');
115-
kernel.use(new ObjectQLPlugin());
115+
await kernel.use(new ObjectQLPlugin());
116116
console.log(chalk.green(` ✓ Registered ObjectQL Plugin (auto-detected)`));
117117
} catch (e: any) {
118118
console.warn(chalk.yellow(` ⚠ Could not auto-load ObjectQL: ${e.message}`));
@@ -126,7 +126,7 @@ export const serveCommand = new Command('serve')
126126
console.log(chalk.dim(` Auto-injecting Memory Driver (Dev Mode)...`));
127127
const { DriverPlugin } = await import('@objectstack/runtime');
128128
const { InMemoryDriver } = await import('@objectstack/driver-memory');
129-
kernel.use(new DriverPlugin(new InMemoryDriver()));
129+
await kernel.use(new DriverPlugin(new InMemoryDriver()));
130130
console.log(chalk.green(` ✓ Registered Memory Driver (auto-detected)`));
131131
} catch (e: any) {
132132
// Silent fail - maybe they don't want a driver or don't have the package
@@ -138,7 +138,7 @@ export const serveCommand = new Command('serve')
138138
if (config.objects || config.manifest || config.apps) {
139139
try {
140140
const { AppPlugin } = await import('@objectstack/runtime');
141-
kernel.use(new AppPlugin(config));
141+
await kernel.use(new AppPlugin(config));
142142
console.log(chalk.green(` ✓ Registered App Plugin (auto-detected)`));
143143
} catch (e: any) {
144144
console.warn(chalk.yellow(` ⚠ Could not auto-load AppPlugin: ${e.message}`));
@@ -166,7 +166,7 @@ export const serveCommand = new Command('serve')
166166
}
167167
}
168168

169-
kernel.use(pluginToLoad);
169+
await kernel.use(pluginToLoad);
170170
const pluginName = plugin.name || plugin.constructor?.name || 'unnamed';
171171
console.log(chalk.green(` ✓ Registered plugin: ${pluginName}`));
172172
} catch (e: any) {
@@ -180,7 +180,7 @@ export const serveCommand = new Command('serve')
180180
try {
181181
const { HonoServerPlugin } = await import('@objectstack/plugin-hono-server');
182182
const serverPlugin = new HonoServerPlugin({ port });
183-
kernel.use(serverPlugin);
183+
await kernel.use(serverPlugin);
184184
console.log(chalk.green(` ✓ Registered HTTP server plugin (port: ${port})`));
185185
} catch (e: any) {
186186
console.warn(chalk.yellow(` ⚠ HTTP server plugin not available: ${e.message}`));

0 commit comments

Comments
 (0)