Skip to content

Commit 6e46535

Browse files
committed
fix: no access for getAlias bug
1 parent ab128b6 commit 6e46535

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

src/modules/scf/index.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -493,29 +493,34 @@ class Scf {
493493
}
494494

495495
// get default alias
496-
const defualtAlias = await this.getAlias({
497-
functionName: funcInfo.FunctionName,
498-
region: this.region,
499-
namespace,
500-
});
501-
if (
502-
defualtAlias &&
503-
defualtAlias.RoutingConfig &&
504-
defualtAlias.RoutingConfig.AdditionalVersionWeights &&
505-
defualtAlias.RoutingConfig.AdditionalVersionWeights.length > 0
506-
) {
507-
const weights = defualtAlias.RoutingConfig.AdditionalVersionWeights;
508-
let weightSum = 0;
509-
let lastVersion = weights[0].Version;
510-
weights.forEach((w) => {
511-
if (Number(w.Version) > Number(outputs.LastVersion)) {
512-
lastVersion = w.Version;
513-
}
514-
weightSum += w.Weight;
496+
// if have no access, ignore it
497+
try {
498+
const defualtAlias = await this.getAlias({
499+
functionName: funcInfo.FunctionName,
500+
region: this.region,
501+
namespace,
515502
});
516-
outputs.LastVersion = lastVersion;
517-
outputs.ConfigTrafficVersion = lastVersion;
518-
outputs.Traffic = 1 - weightSum;
503+
if (
504+
defualtAlias &&
505+
defualtAlias.RoutingConfig &&
506+
defualtAlias.RoutingConfig.AdditionalVersionWeights &&
507+
defualtAlias.RoutingConfig.AdditionalVersionWeights.length > 0
508+
) {
509+
const weights = defualtAlias.RoutingConfig.AdditionalVersionWeights;
510+
let weightSum = 0;
511+
let lastVersion = weights[0].Version;
512+
weights.forEach((w) => {
513+
if (Number(w.Version) > Number(outputs.LastVersion)) {
514+
lastVersion = w.Version;
515+
}
516+
weightSum += w.Weight;
517+
});
518+
outputs.LastVersion = lastVersion;
519+
outputs.ConfigTrafficVersion = lastVersion;
520+
outputs.Traffic = 1 - weightSum;
521+
}
522+
} catch (e) {
523+
// no op
519524
}
520525

521526
if (inputs.tags || inputs.events) {

0 commit comments

Comments
 (0)