Skip to content

Commit fbd103b

Browse files
Copilothotlong
andcommitted
Address code review feedback
- Add documentation for unregisterItem API and fallback mechanism - Add error handling for plugin initialization to prevent silent failures - Log plugin initialization errors while continuing with other plugins Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 99d8165 commit fbd103b

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

  • packages/foundation/core/src

packages/foundation/core/src/app.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ export class ObjectQL implements IObjectQL {
110110
return items.map(unwrapContent);
111111
},
112112
unregister: (type: string, name: string) => {
113-
// Use the official unregisterItem API
113+
// Use the official unregisterItem API when available (added in @objectstack/objectql v0.9.2)
114+
// Fallback to direct metadata access for older versions or test mocks
114115
if (typeof SchemaRegistry.unregisterItem === 'function') {
115116
SchemaRegistry.unregisterItem(type, name);
116117
} else {
@@ -403,11 +404,16 @@ export class ObjectQL implements IObjectQL {
403404

404405
// Manually initialize plugins if kernel doesn't support lifecycle
405406
for (const plugin of this.kernelPlugins) {
406-
if (typeof (plugin as any).init === 'function') {
407-
await (plugin as any).init();
408-
}
409-
if (typeof (plugin as any).start === 'function') {
410-
await (plugin as any).start();
407+
try {
408+
if (typeof (plugin as any).init === 'function') {
409+
await (plugin as any).init();
410+
}
411+
if (typeof (plugin as any).start === 'function') {
412+
await (plugin as any).start();
413+
}
414+
} catch (error) {
415+
console.error(`Failed to initialize plugin ${(plugin as any).name || 'unknown'}:`, error);
416+
// Continue with other plugins even if one fails
411417
}
412418
}
413419
}

0 commit comments

Comments
 (0)