diff --git a/src/lifecycleEvents.ts b/src/lifecycleEvents.ts index 3cc5431f1..494391f3e 100644 --- a/src/lifecycleEvents.ts +++ b/src/lifecycleEvents.ts @@ -238,5 +238,6 @@ export class Lifecycle { } const cloneListeners: (listeners: ListenerMap) => ListenerMap = (listeners) => new Map(Array.from(listeners.entries())); -export const cloneUniqueListeners = (uniqueListeners: UniqueListenerMap): UniqueListenerMap => - new Map(Array.from(uniqueListeners.entries()).map(([key, value]) => [key, cloneListeners(value)])); +export const cloneUniqueListeners = (uniqueListeners: UniqueListenerMap | undefined): UniqueListenerMap => + // in case we're crossing major sfdx-core versions where uniqueListeners might be undefined + new Map(Array.from(uniqueListeners?.entries() ?? []).map(([key, value]) => [key, cloneListeners(value)]));