Skip to content

Commit 8cfb7ea

Browse files
committed
test: updated e2e tracing async function
1 parent 332ffbb commit 8cfb7ea

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

packages/tracing/tests/e2e/tracer.test.DecoratorWithAsyncHandler.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,30 @@ export class MyFunctionWithDecorator {
4949
AWS = tracer.captureAWS(AWS);
5050
stsv2 = new AWS.STS();
5151
}
52-
53-
return Promise.all([
54-
stsv2.getCallerIdentity().promise(),
55-
stsv3.send(new GetCallerIdentityCommand({})),
56-
new Promise((resolve, reject) => {
57-
setTimeout(() => {
58-
const res = this.myMethod();
59-
if (event.throw) {
60-
reject(new Error(customErrorMessage));
61-
} else {
62-
resolve(res);
63-
}
64-
}, 2000); // We need to wait for to make sure previous calls are finished
65-
})
66-
])
67-
.then(([ _stsv2Res, _stsv3Res, promiseRes ]) => promiseRes)
68-
.catch((err) => {
69-
throw err;
70-
});
52+
53+
try {
54+
await stsv2.getCallerIdentity().promise();
55+
} catch (err) {
56+
console.error(err);
57+
}
58+
59+
try {
60+
await stsv3.send(new GetCallerIdentityCommand({}));
61+
} catch (err) {
62+
console.error(err);
63+
}
64+
65+
let res;
66+
try {
67+
res = this.myMethod();
68+
if (event.throw) {
69+
throw new Error(customErrorMessage);
70+
}
71+
} catch (err) {
72+
throw err;
73+
}
74+
75+
return res;
7176
}
7277

7378
@tracer.captureMethod()

0 commit comments

Comments
 (0)