Skip to content

Commit 34df673

Browse files
authored
Fix error on deployment (#4477)
* add try catch * small changes * empty
1 parent 8d8243f commit 34df673

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/commands/createFunctionApp/stacks/getStackPicks.ts

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -380,54 +380,54 @@ export async function showEolWarningIfNecessary(context: ISubscriptionActionCont
380380
}
381381

382382
async function getEOLDate(context: ISubscriptionActionContext, options: eolWarningOptions): Promise<{ endOfLife: Date | undefined, displayVersion: string }> {
383+
let endOfLife: Date | undefined = undefined;
384+
let displayVersion: string = '';
383385
try {
384386
const stacks = options.isFlex ?
385387
(await getFlexStacks(context, options.location)).filter(s => options.runtime === s.value) :
386388
(await getStacks(context)).filter(s => options.runtime === s.value);
387389
const versionFilteredStacks = stacks[0].majorVersions.filter(mv => mv.minorVersions.some(minor => options.isFlex ? minor.stackSettings.linuxRuntimeSettings?.runtimeVersion : minor.stackSettings.windowsRuntimeSettings?.runtimeVersion === options.version));
388390
const filteredStack = versionFilteredStacks[0].minorVersions.find(minor => options.isFlex ? minor.stackSettings.linuxRuntimeSettings?.runtimeVersion : minor.stackSettings.windowsRuntimeSettings?.runtimeVersion === options.version);
389-
const displayVersion = nonNullValue(filteredStack?.displayText);
391+
displayVersion = nonNullValue(filteredStack?.displayText);
390392
const endOfLifeDate = options.isFlex ?
391393
filteredStack?.stackSettings.linuxRuntimeSettings?.endOfLifeDate :
392394
filteredStack?.stackSettings.windowsRuntimeSettings?.endOfLifeDate;
393395
if (endOfLifeDate) {
394-
const endOfLife = new Date(endOfLifeDate)
395-
return {
396-
endOfLife,
397-
displayVersion
398-
}
399-
}
400-
return {
401-
endOfLife: undefined,
402-
displayVersion
403-
}
404-
} catch {
405-
return {
406-
endOfLife: undefined,
407-
displayVersion: ''
396+
endOfLife = new Date(endOfLifeDate)
408397
}
398+
} catch (error) {
399+
// No need to handle the error here
400+
}
401+
402+
return {
403+
endOfLife,
404+
displayVersion
409405
}
406+
410407
}
411408

412409
async function getEOLLinuxFxVersion(context: ISubscriptionActionContext, linuxFxVersion: string): Promise<{ endOfLife: Date | undefined, displayVersion: string }> {
413-
const stacks = (await getStacks(context)).filter(s =>
414-
s.majorVersions.some(mv =>
415-
mv.minorVersions.some(minor => minor.stackSettings.linuxRuntimeSettings?.runtimeVersion === linuxFxVersion)
416-
)
417-
);
418-
const versionFilteredStacks = stacks[0].majorVersions.filter(mv => mv.minorVersions.some(minor => minor.stackSettings.linuxRuntimeSettings?.runtimeVersion === linuxFxVersion));
419-
const filteredStack = versionFilteredStacks[0].minorVersions.find(minor => minor.stackSettings.linuxRuntimeSettings?.runtimeVersion === linuxFxVersion);
420-
const displayVersion = filteredStack?.displayText ?? localize('unknownVersion', 'Unknown version');
421-
const endOfLifeDate = filteredStack?.stackSettings.linuxRuntimeSettings?.endOfLifeDate;
422-
if (endOfLifeDate) {
423-
const endOfLife = new Date(endOfLifeDate)
424-
return {
425-
endOfLife,
426-
displayVersion
410+
let endOfLife: Date | undefined = undefined;
411+
let displayVersion: string = '';
412+
try {
413+
const stacks = (await getStacks(context)).filter(s =>
414+
s.majorVersions.some(mv =>
415+
mv.minorVersions.some(minor => minor.stackSettings.linuxRuntimeSettings?.runtimeVersion === linuxFxVersion)
416+
)
417+
);
418+
const versionFilteredStacks = stacks[0].majorVersions.filter(mv => mv.minorVersions.some(minor => minor.stackSettings.linuxRuntimeSettings?.runtimeVersion === linuxFxVersion));
419+
const filteredStack = versionFilteredStacks[0].minorVersions.find(minor => minor.stackSettings.linuxRuntimeSettings?.runtimeVersion === linuxFxVersion);
420+
displayVersion = filteredStack?.displayText ?? localize('unknownVersion', 'Unknown version');
421+
const endOfLifeDate = filteredStack?.stackSettings.linuxRuntimeSettings?.endOfLifeDate;
422+
if (endOfLifeDate) {
423+
endOfLife = new Date(endOfLifeDate)
427424
}
425+
} catch (error) {
426+
// No need to handle the error here
428427
}
428+
429429
return {
430-
endOfLife: undefined,
430+
endOfLife,
431431
displayVersion
432432
}
433433
}

0 commit comments

Comments
 (0)