@@ -100,8 +100,9 @@ export class VersionsDataSource {
100
100
}
101
101
102
102
private async getVersionMetadata ( ) : Promise < Record < string , string > > {
103
+ const now = new Date ( ) . toISOString ( )
103
104
const DEFAULT_RESPONSE = {
104
- [ pkg . version ] : new Date ( ) . toISOString ( ) ,
105
+ [ pkg . version ] : now ,
105
106
}
106
107
107
108
if ( this . ctx . isRunMode ) {
@@ -112,21 +113,18 @@ export class VersionsDataSource {
112
113
113
114
try {
114
115
response = await this . ctx . util . fetch ( NPM_CYPRESS_REGISTRY )
116
+ const responseJson = await response . json ( ) as { time : Record < string , string > }
117
+
118
+ debug ( 'NPM release dates received %o' , { modified : responseJson . time . modified } )
119
+
120
+ return responseJson . time ?? now
115
121
} catch ( e ) {
116
122
// ignore any error from this fetch, they are gracefully handled
117
123
// by showing the current version only
118
124
debug ( 'Error fetching %o' , NPM_CYPRESS_REGISTRY , e )
119
- }
120
125
121
- if ( ! response ) {
122
126
return DEFAULT_RESPONSE
123
127
}
124
-
125
- const responseJson = await response . json ( ) as { time : Record < string , string > }
126
-
127
- debug ( 'NPM release dates received %o' , { modified : responseJson . time . modified } )
128
-
129
- return responseJson . time
130
128
}
131
129
132
130
private async getLatestVersion ( ) : Promise < string > {
@@ -153,31 +151,27 @@ export class VersionsDataSource {
153
151
manifestHeaders [ 'x-machine-id' ] = id
154
152
}
155
153
156
- let manifestResponse
157
-
158
154
try {
159
- manifestResponse = await this . ctx . util . fetch ( url , {
155
+ const manifestResponse = await this . ctx . util . fetch ( url , {
160
156
headers : manifestHeaders ,
161
157
} )
158
+
159
+ debug ( 'retrieving latest version information with headers: %o' , manifestHeaders )
160
+
161
+ const manifest = await manifestResponse . json ( ) as { version : string }
162
+
163
+ debug ( 'latest version information: %o' , manifest )
164
+
165
+ return manifest . version ?? pkg . version
162
166
} catch ( e ) {
163
167
// ignore any error from this fetch, they are gracefully handled
164
168
// by showing the current version only
165
169
debug ( 'Error fetching %o' , url , e )
166
- }
167
170
168
- if ( ! manifestResponse ) {
169
171
return pkg . version
172
+ } finally {
173
+ this . _initialLaunch = false
170
174
}
171
-
172
- debug ( 'retrieving latest version information with headers: %o' , manifestHeaders )
173
-
174
- const manifest = await manifestResponse . json ( ) as { version : string }
175
-
176
- debug ( 'latest version information: %o' , manifest )
177
-
178
- this . _initialLaunch = false
179
-
180
- return manifest . version
181
175
}
182
176
183
177
private static async machineId ( ) : Promise < string | undefined > {
0 commit comments