From 4a8cd91a325938cecfd5982b719f2d259b5d889f Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 12 Nov 2024 14:56:50 +0100 Subject: [PATCH] Ensure JavaScript Ice/ami test awaits all requests - Fix #3130 (#3130) --- js/test/Ice/ami/Client.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/js/test/Ice/ami/Client.ts b/js/test/Ice/ami/Client.ts index 91bc9fd06b3..8c7b980b0a3 100644 --- a/js/test/Ice/ami/Client.ts +++ b/js/test/Ice/ami/Client.ts @@ -159,11 +159,13 @@ export class Client extends TestHelper { // Safari WebSocket implementation accepts lots of data before apply back-pressure // making this test very slow. await testController.holdAdapter(); + const requests: Ice.AsyncResult[] = []; try { r1 = p.op(); const seq = new Uint8Array(100000); while (true) { r2 = p.opWithPayload(seq); + requests.push(r2); if (r2.sentSynchronously()) { await Ice.Promise.delay(0); } else { @@ -171,17 +173,15 @@ export class Client extends TestHelper { } } - if ((await p.ice_getConnection()) !== null) { - test( - (r1.sentSynchronously() && r1.isSent() && !r1.isCompleted()) || - (!r1.sentSynchronously() && !r1.isCompleted()), - ); + test( + (r1.sentSynchronously() && r1.isSent() && !r1.isCompleted()) || + (!r1.sentSynchronously() && !r1.isCompleted()), + ); - test(!r2.sentSynchronously() && !r2.isCompleted()); + test(!r2.sentSynchronously() && !r2.isCompleted()); - test(!r1.isCompleted()); - test(!r2.isCompleted()); - } + test(!r1.isCompleted()); + test(!r2.isCompleted()); } finally { await testController.resumeAdapter(); } @@ -194,6 +194,8 @@ export class Client extends TestHelper { test(r2.isSent()); test(r2.isCompleted()); + await Promise.all(requests); + test(r1.operation == "op"); test(r2.operation == "opWithPayload"); } @@ -243,8 +245,10 @@ export class Client extends TestHelper { await testController.holdAdapter(); const seq = new Uint8Array(new Array(100000)); let r; + let requests: Ice.AsyncResult[] = []; while (true) { r = p.opWithPayload(seq); + requests.push(r); if (r.sentSynchronously()) { await Ice.Promise.delay(0); } else { @@ -270,7 +274,7 @@ export class Client extends TestHelper { r2.cancel(); await testController.resumeAdapter(); - await r; + await Promise.all(requests); test(!r1.isSent() && r1.isCompleted()); test(!r2.isSent() && r2.isCompleted());