Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocha tests fixed and enabled in travis config. #541

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

koral--
Copy link
Member

@koral-- koral-- commented Feb 14, 2017

I've tried to add some tests related to #538 but realized that they are not executed on travis.
After fixing configs it turns out that one of your tests (keyutil parseKeyCharacterMap) is failing.

@lukzeg
Copy link
Contributor

lukzeg commented Sep 16, 2019

Hi @koral--

Mostly looks like we are trying to read not ready stream. I think we should add check:

diff --git a/lib/util/keyutil.js b/lib/util/keyutil.js
index cf494c9..9adf075 100644
--- a/lib/util/keyutil.js
+++ b/lib/util/keyutil.js
@@ -427,17 +427,20 @@ keyutil.parseKeyCharacterMap = function(stream) {
   }
 
   function readableListener() {
-    var chunk = stream.read()
-    var i = 0
-    var l = chunk.length
+    var chunk
 
-    try {
-      while (i < l) {
-        parse(String.fromCharCode(chunk[i++]))
+    while ((chunk = stream.read()) !== null) {
+      var i = 0
+      var l = chunk.length
+
+      try {
+        while (i < l) {
+          parse(String.fromCharCode(chunk[i++]))
+        }
+      }
+      catch (err) {
+        resolver.reject(err)
       }
-    }
-    catch (err) {
-      resolver.reject(err)
     }
   }

This change will fix the problem with

Uncaught TypeError: Cannot read property 'length' of null

error mentioned in :https://travis-ci.org/openstf/stf/jobs/201676025

Should I create separate PR with fix for it?

I double checked the changes and I did not observed any issues on live running STF.

Fix base on comment:
https://stackoverflow.com/questions/21549161/readable-event-occurs-twice/22751069

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants