@@ -29,33 +29,34 @@ export async function diffEnvs(
29
29
const matched : string [ ] = [ ] ;
30
30
const conflicts : string [ ] = [ ] ;
31
31
32
- // Note: Can conceivably optimize this by parallelizing lookups of secret values with fetchSecrets.
33
- // Unlikely to actually cause noticeable benefits.
34
- for ( const [ key , value ] of Object . entries ( envs ) ) {
35
- const existingEnv = config . findEnv ( doc , key ) ;
36
- if ( ! existingEnv ) {
37
- newVars . push ( key ) ;
38
- continue ;
39
- }
32
+ await Promise . all (
33
+ Object . entries ( envs ) . map ( async ( [ key , value ] ) => {
34
+ const existingEnv = config . findEnv ( doc , key ) ;
35
+ if ( ! existingEnv ) {
36
+ newVars . push ( key ) ;
37
+ return ;
38
+ }
40
39
41
- let match = false ;
42
- if ( existingEnv . value ) {
43
- match = existingEnv . value === value ;
44
- } else {
45
- try {
46
- match =
47
- value ===
48
- ( await secretManager . accessSecretVersion ( projectId , existingEnv . secret ! , "latest" ) ) ;
49
- } catch ( err ) {
50
- utils . logLabeledWarning (
51
- "apphosting" ,
52
- `Cannot read value of existing secret ${ existingEnv . secret ! } to see if it has changed. Assuming it has changed.` ,
53
- ) ;
40
+ let match = false ;
41
+ if ( existingEnv . value ) {
42
+ match = existingEnv . value === value ;
43
+ } else {
44
+ try {
45
+ match =
46
+ value ===
47
+ ( await secretManager . accessSecretVersion ( projectId , existingEnv . secret ! , "latest" ) ) ;
48
+ } catch ( err ) {
49
+ utils . logLabeledWarning (
50
+ "apphosting" ,
51
+ `Cannot read value of existing secret ${ existingEnv . secret ! } to see if it has changed. Assuming it has changed.` ,
52
+ ) ;
53
+ }
54
54
}
55
- }
56
55
57
- ( match ? matched : conflicts ) . push ( key ) ;
58
- }
56
+ ( match ? matched : conflicts ) . push ( key ) ;
57
+ } ) ,
58
+ ) ;
59
+
59
60
return { newVars, matched, conflicts } ;
60
61
}
61
62
0 commit comments