@@ -35,10 +35,9 @@ export interface StorageParameters {
35
35
bucket : Bucket | null ;
36
36
checkId : string ;
37
37
executionId : string ;
38
+ screenshotNumber : number ;
38
39
}
39
40
40
- let SCREENSHOT_NUMBER = 1 ;
41
-
42
41
/**
43
42
* Attempts to get an existing storage bucket if provided by the user OR
44
43
* create/use a dedicated synthetics bucket.
@@ -56,15 +55,13 @@ export async function getOrCreateStorageBucket(
56
55
storageLocation : string ,
57
56
errors : BaseError [ ]
58
57
) : Promise < Bucket | null > {
59
- SCREENSHOT_NUMBER = 1 ;
60
58
let bucketName = '' ;
61
59
62
60
try {
63
61
if ( ! storageClient ) return null ;
64
62
65
63
const projectId = sanitizeObjectName ( await resolveProjectId ( ) ) ;
66
64
const region = sanitizeObjectName ( await getExecutionRegion ( ) ) ;
67
- // const region = "us-east4"
68
65
69
66
// if the user chose to use/create the default bucket but we were not able
70
67
// to resolve projectId or cloudRegion
@@ -160,7 +157,7 @@ export async function uploadScreenshotToGCS(
160
157
}
161
158
162
159
const screenshot : Buffer = await page . screenshot ( { encoding : 'binary' } ) ;
163
- const filename = 'screenshot_' + SCREENSHOT_NUMBER + '.png' ;
160
+ const filename = 'screenshot_' + storageParams . screenshotNumber + '.png' ;
164
161
165
162
const writeDestination = path . join (
166
163
getStoragePathToExecution ( storageParams , options ) ,
@@ -172,7 +169,7 @@ export async function uploadScreenshotToGCS(
172
169
contentType : 'image/png' ,
173
170
} ) ;
174
171
175
- SCREENSHOT_NUMBER += 1 ;
172
+ storageParams . screenshotNumber += 1 ;
176
173
screenshot_output . screenshot_file = filename ;
177
174
} catch ( err ) {
178
175
// Handle upload errors
0 commit comments