You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by GitBox <gi...@apache.org> on 2022/06/28 04:36:14 UTC

[GitHub] [tinkerpop] lyndonbauto commented on a diff in pull request #1736: TINKERPOP-2754 Fix indefinite hanging on JS client on server restart

lyndonbauto commented on code in PR #1736:
URL: https://github.com/apache/tinkerpop/pull/1736#discussion_r908020957


##########
gremlin-javascript/src/main/javascript/gremlin-javascript/test/integration/client-tests.js:
##########
@@ -107,5 +107,48 @@ describe('Client', function () {
       assert.strictEqual(output.length, 3);
       assert.ok(output[0] instanceof graphModule.Vertex);
     });
+
+    it("should reject pending traversal promises if connection closes", async () => {
+      const closingClient = helper.getClient('gmodern');
+      await closingClient.open();
+      const timeout = 10000;
+      const startTime = Date.now();
+      let isRejected = false;
+      
+      const pending = async function submitTraversals() {
+        while (Date.now() < startTime + timeout) {
+          try {
+            await closingClient.submit(new Bytecode().addStep('V', []).addStep('tail', []));
+          } catch (e) {
+            isRejected = true;
+            return;
+          }
+        }
+      };
+      const pendingPromise = pending();
+
+      await closingClient.close();
+      await pendingPromise;
+      assert.strictEqual(isRejected, true);
+    });
+
+    it("should end streams on traversals if connection closes", async () => {
+      const closingClient = helper.getClient('gmodern');
+      await closingClient.open();
+      let isRejected = false;
+
+      const readable = client.stream('g.V().limit(3)', {}, { batchSize: 2 });
+
+      readable.on('end', () => {
+        isRejected = true;
+      });
+
+      await closingClient.close();
+      for await (const result of readable) {
+        // Consume the stream
+      }
+
+      assert.strictEqual(isRejected, true);
+    });
   });
 });

Review Comment:
   ```suggestion
   });
   
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org