Skip to content

Commit 78423ea

Browse files
authored
test(toolkit): Stub all instances of process.hrtime in records perfomance test (aws#5503)
## Problem We're seeing some flakiness with the `TelemetrySpan records performance` test. I _think_ it could be related to the fact we [stub certain calls on process.hrtime](https://github.com/aws/aws-toolkit-vscode/blob/master/packages/core/src/test/utilities/performance.ts#L21) instead of stubbing all instances. This can potentially cause [nodeClock](https://github.com/aws/aws-sdk-js/blob/master/lib/realclock/nodeClock.js#L4) to use or not use stubbed values depending on when things are executed. Previously we would see a failure this: ``` TypeError: Cannot read properties of undefined (reading '0') at Object.now (/codebuild/output/src575830969/src/github.com/aws/aws-toolkit-vscode/node_modules/aws-sdk/lib/realclock/nodeClock.js:5:18) ``` ## Solution Stub all instances of process.hrtime during that test
1 parent 5afea02 commit 78423ea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/core/src/test/utilities/performance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export function stubPerformance(sandbox: Sinon.SinonSandbox) {
1818
.returns({ heapTotal: initialHeapTotal, arrayBuffers: 0, external: 0, rss: 0, heapUsed: 0 })
1919
memoryUsageStub.onCall(1).returns({ heapTotal: 10485761, arrayBuffers: 0, external: 0, rss: 0, heapUsed: 0 })
2020

21-
sandbox.stub(process, 'hrtime').onCall(0).returns([0, 0]).onCall(1).returns([0, totalNanoseconds])
21+
sandbox.stub(process, 'hrtime').returns([0, totalNanoseconds])
2222

2323
return {
2424
expectedUserCpuUsage: 33.333333333333336,

0 commit comments

Comments
 (0)