@@ -5560,9 +5560,28 @@ export class ObjectQL implements IObjectQLEngine {
55605560 * action's declared param contract at dispatch before the handler runs.
55615561 * The seam itself stays untyped so existing untyped handlers keep working.
55625562 * @param packageName Optional package owner (for cleanup)
5563+ *
5564+ * [#24472] A key another package already holds is still replaced — the last
5565+ * registration runs, as before — but no longer silently: the replacement is
5566+ * warned, naming both owners. The same owner re-registering (a re-bind, a
5567+ * reload, the authored-action resync, which tears its set down first) is
5568+ * not. A registration with no `packageName` is its own owner here, so it
5569+ * replacing a package's handler, or the reverse, is warned too.
55635570 */
55645571 registerAction(objectName: string, actionName: string, handler: (ctx: any) => Promise<any> | any, packageName?: string): void {
55655572 const key = `${objectName}:${actionName}`;
5573+ const replaced = this.actions.get(key);
5574+ if (replaced !== undefined && replaced.package !== packageName) {
5575+ const owner = (name: string | undefined) => (name ? `package '${name}'` : 'a registration with no package');
5576+ this.logger.warn(
5577+ `Action handler '${key}' registered by ${owner(packageName)} replaces the one ${owner(replaced.package)} `
5578+ + `registered: the action door now runs the handler of ${owner(packageName)}, whichever declaration `
5579+ + `object '${objectName}' lists, and withdrawing ${owner(packageName)} leaves the action with no handler. `
5580+ + `Two owners share one handler key only when both declare action '${actionName}' on object `
5581+ + `'${objectName}' — rename one of them.`,
5582+ { objectName, actionName, package: packageName, replacedPackage: replaced.package },
5583+ );
5584+ }
55665585 this.actions.set(key, { handler, package: packageName });
55675586 this.logger.debug('Registered action', { objectName, actionName, package: packageName });
55685587 }
0 commit comments