Add aggressive debugging logs to trace hook execution

- Add console.log statements that will ALWAYS appear if hooks are called
- Trace WorkflowExecutor creation and method availability
- Log every step of hook execution pipeline
- This will help identify exactly where the execution is failing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-01 20:47:38 +02:00
parent c24610b3d9
commit 08a4022a41
7 changed files with 482 additions and 0 deletions

View File

@@ -787,6 +787,13 @@ export class WorkflowExecutor {
previousDoc: unknown,
req: PayloadRequest
): Promise<void> {
console.log('🚨 EXECUTOR: executeTriggeredWorkflows called!')
console.log('🚨 EXECUTOR: Collection =', collection)
console.log('🚨 EXECUTOR: Operation =', operation)
console.log('🚨 EXECUTOR: Doc ID =', (doc as any)?.id)
console.log('🚨 EXECUTOR: Has payload?', !!this.payload)
console.log('🚨 EXECUTOR: Has logger?', !!this.logger)
this.logger.info({
collection,
operation,

View File

@@ -79,11 +79,16 @@ export const workflowsPlugin =
logger.info(`Plugin configuration: ${Object.keys(pluginOptions.collectionTriggers || {}).length} collection triggers, ${pluginOptions.steps?.length || 0} steps`)
// Create workflow executor instance
console.log('🚨 CREATING WORKFLOW EXECUTOR INSTANCE')
const executor = new WorkflowExecutor(payload, logger)
console.log('🚨 EXECUTOR CREATED:', typeof executor)
console.log('🚨 EXECUTOR METHODS:', Object.getOwnPropertyNames(Object.getPrototypeOf(executor)))
// Initialize hooks
console.log('🚨 INITIALIZING COLLECTION HOOKS')
logger.info('Initializing collection hooks...')
initCollectionHooks(pluginOptions, payload, logger, executor)
console.log('🚨 COLLECTION HOOKS INITIALIZATION COMPLETE')
logger.info('Initializing global hooks...')
initGlobalHooks(payload, logger, executor)

View File

@@ -39,14 +39,27 @@ export function initCollectionHooks<T extends string>(pluginOptions: WorkflowsPl
collection.config.hooks.afterChange = collection.config.hooks.afterChange || []
collection.config.hooks.afterChange.push(async (change) => {
const operation = change.operation as 'create' | 'update'
// AGGRESSIVE LOGGING - this should ALWAYS appear
console.log('🚨 AUTOMATION PLUGIN HOOK CALLED! 🚨')
console.log('Collection:', change.collection.slug)
console.log('Operation:', operation)
console.log('Doc ID:', change.doc?.id)
console.log('Has executor?', !!executor)
console.log('Executor type:', typeof executor)
logger.info({
slug: change.collection.slug,
operation,
docId: change.doc?.id,
previousDocId: change.previousDoc?.id,
hasExecutor: !!executor,
executorType: typeof executor
}, 'AUTOMATION PLUGIN: Collection hook triggered')
try {
console.log('🚨 About to call executeTriggeredWorkflows')
// Execute workflows for this trigger
await executor.executeTriggeredWorkflows(
change.collection.slug,
@@ -55,12 +68,17 @@ export function initCollectionHooks<T extends string>(pluginOptions: WorkflowsPl
change.previousDoc,
change.req
)
console.log('🚨 executeTriggeredWorkflows completed without error')
logger.info({
slug: change.collection.slug,
operation,
docId: change.doc?.id
}, 'AUTOMATION PLUGIN: executeTriggeredWorkflows completed successfully')
} catch (error) {
console.log('🚨 AUTOMATION PLUGIN ERROR:', error)
logger.error({
slug: change.collection.slug,
operation,