@@ -10,9 +10,9 @@ dotenv.config();
10
10
11
11
const puppeteerCacheDir = join ( homedir ( ) , '.cache' , 'puppeteer' ) ;
12
12
13
- // Guard to prevent multiple executions
14
- let hasRunOnSuccess = false ;
15
- let hasRunOnPostBuild = false ;
13
+ // Global guard to prevent multiple executions across all plugin instances
14
+ global . lighthouseHasRunOnSuccess = global . lighthouseHasRunOnSuccess || false ;
15
+ global . lighthouseHasRunOnPostBuild = global . lighthouseHasRunOnPostBuild || false ;
16
16
17
17
const onPreBuild = async ( { utils } = { } ) => {
18
18
console . log ( 'onPreBuild handler called' ) ;
@@ -29,7 +29,7 @@ const persistCache = async ({ utils } = {}) => {
29
29
} ;
30
30
31
31
export default function lighthousePlugin ( inputs ) {
32
- console . log ( 'lighthouse plugin function called with inputs:' , JSON . stringify ( inputs , null , 2 ) ) ;
32
+ console . log ( '🚨 LIGHTHOUSE PLUGIN FUNCTION CALLED with inputs:' , JSON . stringify ( inputs , null , 2 ) ) ;
33
33
// Run onSuccess by default, unless inputs specify we should fail_deploy_on_score_thresholds
34
34
const defaultEvent =
35
35
inputs ?. fail_deploy_on_score_thresholds === 'true'
@@ -46,11 +46,11 @@ export default function lighthousePlugin(inputs) {
46
46
onSuccess : async ( { constants, utils, inputs } = { } ) => {
47
47
console . log ( 'onSuccess handler called' ) ;
48
48
49
- if ( hasRunOnSuccess ) {
50
- console . log ( 'onSuccess already executed, skipping duplicate call' ) ;
49
+ if ( global . lighthouseHasRunOnSuccess ) {
50
+ console . log ( '⚠️ onSuccess already executed, skipping duplicate call' ) ;
51
51
return ;
52
52
}
53
- hasRunOnSuccess = true ;
53
+ global . lighthouseHasRunOnSuccess = true ;
54
54
55
55
// Mock the required `utils` functions if running locally
56
56
const { failPlugin, show } = getUtils ( { utils } ) ;
@@ -70,11 +70,11 @@ export default function lighthousePlugin(inputs) {
70
70
onPostBuild : async ( { constants, utils, inputs } = { } ) => {
71
71
console . log ( 'onPostBuild handler called (onPostBuild mode)' ) ;
72
72
73
- if ( hasRunOnPostBuild ) {
74
- console . log ( 'onPostBuild already executed, skipping duplicate call' ) ;
73
+ if ( global . lighthouseHasRunOnPostBuild ) {
74
+ console . log ( '⚠️ onPostBuild already executed, skipping duplicate call' ) ;
75
75
return ;
76
76
}
77
- hasRunOnPostBuild = true ;
77
+ global . lighthouseHasRunOnPostBuild = true ;
78
78
79
79
// Mock the required `utils` functions if running locally
80
80
const { failBuild, show } = getUtils ( { utils } ) ;
0 commit comments