зеркало из https://github.com/Azure/autorest.git
Fix: Uncaught promise exception when plugin has no dependent (#4105)
* fix promises * change
This commit is contained in:
Родитель
a70dda6f00
Коммит
4790de64e5
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"changes": [
|
||||
{
|
||||
"packageName": "@autorest/core",
|
||||
"comment": "**Fix** Uncaught promise exception",
|
||||
"type": "patch"
|
||||
}
|
||||
],
|
||||
"packageName": "@autorest/core",
|
||||
"email": "tiguerin@microsoft.com"
|
||||
}
|
|
@ -9,16 +9,15 @@ export class OutstandingTaskAwaiter {
|
|||
private locked = false;
|
||||
private outstandingTasks: Array<Promise<any>> = [];
|
||||
|
||||
public async Wait(): Promise<void> {
|
||||
public async wait(): Promise<void> {
|
||||
this.locked = true;
|
||||
await Promise.all(this.outstandingTasks);
|
||||
}
|
||||
|
||||
public async Await<T>(task: Promise<T>): Promise<T> {
|
||||
public await<T>(task: Promise<T>) {
|
||||
if (this.locked) {
|
||||
throw new OutstandingTaskAlreadyCompletedException();
|
||||
}
|
||||
this.outstandingTasks.push(task);
|
||||
return task;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -429,17 +429,17 @@ export async function runPipeline(configView: AutorestContext, fileSystem: IFile
|
|||
taskx._finishedAt = Date.now();
|
||||
})
|
||||
.catch(() => (taskx._state = "failed"));
|
||||
void barrier.Await(task);
|
||||
void barrierRobust.Await(task.catch(() => {}));
|
||||
barrier.await(task);
|
||||
barrierRobust.await(task.catch(() => {}));
|
||||
}
|
||||
|
||||
try {
|
||||
await barrier.Wait();
|
||||
await barrier.wait();
|
||||
await emitStats(configView);
|
||||
} catch (e) {
|
||||
// wait for outstanding nodes
|
||||
try {
|
||||
await barrierRobust.Wait();
|
||||
await barrierRobust.wait();
|
||||
} catch {
|
||||
// wait for others to fail or whatever...
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче