Skip to content

Commit ba1975d

Browse files
committed
retry
1 parent 8958fd2 commit ba1975d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ dotenv.config();
1010

1111
const puppeteerCacheDir = join(homedir(), '.cache', 'puppeteer');
1212

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;
1616

1717
const onPreBuild = async ({ utils } = {}) => {
1818
console.log('onPreBuild handler called');
@@ -29,7 +29,7 @@ const persistCache = async ({ utils } = {}) => {
2929
};
3030

3131
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));
3333
// Run onSuccess by default, unless inputs specify we should fail_deploy_on_score_thresholds
3434
const defaultEvent =
3535
inputs?.fail_deploy_on_score_thresholds === 'true'
@@ -46,11 +46,11 @@ export default function lighthousePlugin(inputs) {
4646
onSuccess: async ({ constants, utils, inputs } = {}) => {
4747
console.log('onSuccess handler called');
4848

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');
5151
return;
5252
}
53-
hasRunOnSuccess = true;
53+
global.lighthouseHasRunOnSuccess = true;
5454

5555
// Mock the required `utils` functions if running locally
5656
const { failPlugin, show } = getUtils({ utils });
@@ -70,11 +70,11 @@ export default function lighthousePlugin(inputs) {
7070
onPostBuild: async ({ constants, utils, inputs } = {}) => {
7171
console.log('onPostBuild handler called (onPostBuild mode)');
7272

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');
7575
return;
7676
}
77-
hasRunOnPostBuild = true;
77+
global.lighthouseHasRunOnPostBuild = true;
7878

7979
// Mock the required `utils` functions if running locally
8080
const { failBuild, show } = getUtils({ utils });

0 commit comments

Comments
 (0)