tedious: Pausing and resuming is causing the stream to remain stuck

We are running into an issue where the tedious stream remains stuck if the stream is paused and resumed multiple times. The stream is not resumed even though certain rows should be emitted into the stream pipeline.

It seems to be related to the data as this problem does not occur if the data is changed.

A script is attached to reproduce this problem. An npm install should be performed and the database authentication settings should be adjusted inside the script.

test_pause_and_resume.zip

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Again, thank you for the report and the test case. Based on the test case, I was able to track down the issue and build a proper fix:

diff --git a/src/incoming-message-stream.js b/src/incoming-message-stream.js
index 65c16d3..6c83497 100644
--- a/src/incoming-message-stream.js
+++ b/src/incoming-message-stream.js
@@ -64,13 +64,24 @@ class IncomingMessageStream extends Transform {
         }
 
         if (packet.isLast()) {
-          this.currentMessage = undefined;
-          // Wait until the current message was fully processed before we
-          // continue processing any remaining messages.
-          message.once('end', () => {
-            this.processBufferedData(callback);
-          });
-          message.end(packet.data());
+          const endMessage = () => {
+            this.currentMessage = undefined;
+
+            // Wait until the current message was fully processed before we
+            // continue processing any remaining messages.
+            message.once('end', () => {
+              this.processBufferedData(callback);
+            });
+
+            message.end(packet.data());
+          };
+
+          if (message.isPaused()) {
+            message.on('resume', endMessage);
+          } else {
+            endMessage();
+          }
+
           return;
         } else {
           this.currentMessage = message;

I’ll open a proper PR and push a new release as soon as I can. In the meantime, feel free to test using the above patch and let me know if that fixes the issue for you too! 🙇