[NodeJS][mocha] Builds randomly succeed/fail, including when rebuilding the same commit

l3l_aze's Avatar


15 Mar, 2018 09:06 AM

My project has been randomly succeeding/failing and I cannot figure out how to stabilize it any better than I have. I am an amateur to all of this, but I think my testing code is okay -- it does work fine over on Travis-CI building on both Mac and Ubuntu Linux (except in cases where a web request randomly fails -- another thing I need to stabilize, but AV has been a much worse issue so I've concentrated on that so far).

It's not even consistent about the errors, either -- sometimes it's one file, other times it can be a different file in the same test case. Lol. Sometimes the errors cause other errors in mocha's test-runner, and sometimes they do not.

I'm not sure if it's my test code, the code that it's running, mocha, or the AV servers, but it's gotten quite annoying and I'd really like to stop needing to rebuild the project here on AV anywhere between 1 and 10 times to get a commit to build properly while Travis almost always succeeds in one try.

  1. Support Staff 1 Posted by Owen McDonnell on 19 Mar, 2018 05:29 PM

    Owen McDonnell's Avatar

    I forked the project and tried a few different appveyor.yml settings. You can check out my builds here.
    Here are some of my thoughts,

    • the section in your test.js file (possibly other places as well) that checks for CI environment variable if (process.env.CI === true) does not seem to be working as intended in windows build environment. I changed to if (process.env.CI === 'True') to get what i interpret as the intended flow.

    • the determination of process architecture section that follows that also doesn't seem to be working properly (though perhaps there is some reason for this approach that is just not clear to me)...

      if (arch === 'ia32') {
        pathTo = path.join('C:', 'Program Files', 'Steam')
      } else if (arch === 'ia64') {
        pathTo = path.join('C:', 'Program Files (x86)', 'Steam')
      but also, for both jobs in the build the 32 bit version of node is being used.
      To remedy this, i changed the environment setting in appveyor.yml to,
          - nodejs_version: 8
      instead of,
        nodejs_version: 8
      which is what you had.
    • finally, i tried on appveyor's new ubuntu image with the equivalent of your travis settings and, although i got a much higher build success rate there were still stochastic errors.

    Do you think its possible that there are some async problems in your testing code that are becoming more error prone in a windows environment?

  2. Support Staff 2 Posted by Owen McDonnell on 19 Mar, 2018 05:31 PM

    Owen McDonnell's Avatar

    Also, of note, a very high number of the errors seem to be a web request to a steam server.

     1) SteamPaths
           "before each" hook for "should get the list of owned apps from the cache":
         TypeError: Cannot read property 'call' of undefined
    Perhaps there is a timeout adjustment that can be made?
  3. 3 Posted by l3l_aze on 20 Mar, 2018 10:00 AM

    l3l_aze's Avatar

    I thought I had commented, but apparently I can't even do that right. Yay.

    Yeah, I knew about the issue with the errors requesting the owned apps from the server; that one above is a special case though which seems to only happen when something else errors out above and Mocha is apparently internally broken.

    I have implemented your fixes and it does seem far more stable -- thank you for your help there -- but of course it's still randomly failing whenever it feels like it.

    I also tried using Jest (with the use-jest branch), but that's having random issues too, and not even when using a CI but directly on my machine.

    It's obviously an issue deeper in my code, but I'm new to async/await, callbacks, and Promises and have basically no idea what I'm doing when things go bad even after reading more tutorials than I can possibly remember.

    I'm sorry to have wasted your time. Thank you.

  4. Support Staff 4 Posted by Owen McDonnell on 20 Mar, 2018 03:16 PM

    Owen McDonnell's Avatar

    Not a waste, I'm actually relatively new to the Appveyor support team myself so we're a good match! And i know from experience javascript async/await can be tricky business. I'm sure you have read more articles then you wanted to troubleshooting this but here is one more that might prove relevant.
    Also, as you are building for linux I thought i'd let you know, we have recently added Ubuntu build worker images to Appveyor. If your are interested in giving the beta a try let me know and I can add an image to your account.

  5. 5 Posted by l3l_aze on 20 Mar, 2018 11:43 PM

    l3l_aze's Avatar

    LoL; I just randomly read that article a few minutes ago; it did help me realize part of the issues along with this one -- I have some async code in map/filter/forEach functions =\

    Trying to fix it now, but it's just causing more and more issues, and I'll probably end up having to rebuild everything again from the ground up. Would be nice to refactor some things of course, but this is already at least the sixth iteration and every time I so much as look at this project any more I just want to take it out back and beat it to death without bothering to print it out from the computer first.

    Thank you for the offer, but with how terrible everything I touch has been lately I don't want to affect the beta, and I'm nowhere near ready to do beta testing for anything with my terrible-amateur-proof-of-concept-alpha projects.

    Thank you for your help; you have been awesome.

  6. 6 Posted by l3l_aze on 22 Mar, 2018 01:22 AM

    l3l_aze's Avatar

    Fixed most of it, issues with using async code in non-async functions and the like which were all me from the beginning and not AppVeyor or Mocha, but a dependency of NYC (code coverage tool) updated this morning and broke that completely... So, my lucky streak is still going.

    Now aren't you glad I'm not in the beta? Lmao.

  7. Support Staff 7 Posted by Owen McDonnell on 22 Mar, 2018 02:53 AM

    Owen McDonnell's Avatar

    Life of a javascript developer :)

  8. 8 Posted by l3l_aze on 22 Mar, 2018 06:14 AM

    l3l_aze's Avatar


    Everything is still broken (only on the CI's) after removing nyc now...but different -- now it's throwing an error when trying to use the created dummy path even though none of that code has changed. I thought it may be because Node released a new LTS version: 8.10.0 instead of 8.9.4, but even when locking Travis-CI and AppVeyor to 8.9.4 it's still screwed.

    If you see someone on the news rioting and rampaging, smashing every damn machine in sight, you know who it is. I'll try to remember to wave, but honestly by that point I will no longer be part of this world.

    And if it's not already marked for it please feel free to close this.

    Thank you for all you tried to do; see you at my trial.

    Last edit: After reverting to a commit made this morning yet again (at least the fifth or sixth time) and running that on CI's again (at least the millionth time) it's somehow working again. Still planning to be on the news.

  9. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:27 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac