Fix infinite loop when connecting companion
Fix infinite loop when connecting companion

A user reported an issue with a project where connecting the companion
caused the ReplMgr to go into an infinite loop. The issue was due to a
combination of setter block having an empty socket (triggering an
error resulting in the slow path) and the fact that there were more
than 20 top-level blocks in the project. After testing the first 20
blocks it would attempt the fast path, which would retrigger the slow
path, ad infinitum.

This commit updates the countdown in the slow path to use the number
of top-level blocks in the workspace rather than hard-coding 20
checks.

Fixes #887

Change-Id: Ie15b0f35cd145ecc0b789707f032eca6c179d107

jisqyv/appinventor-sources,halatmit/appinventor-sources,lizlooney/appinventor-sources,afmckinney/appinventor-sources,lizlooney/appinventor-sources,halatmit/appinventor-sources,CoderDojoLX/appinventor-sources,puravidaapps/appinventor-sources,lizlooney/appinventor-sources,josmas/app-inventor,barreeeiroo/appinventor-sources,lizlooney/appinventor-sources,mit-dig/punya,kkashi01/appinventor-sources,mit-cml/appinventor-sources,farxinu/appinventor-sources,jisqyv/appinventor-sources,ewpatton/appinventor-sources,halatmit/appinventor-sources,farxinu/appinventor-sources,thequixotic/appinventor-sources,Klomi/appinventor-sources,marksherman/appinventor-sources,ewpatton/appinventor-sources,themadrobot/appinventor-sources,RachaelT/appinventor-sources,themadrobot/appinventor-sources,Klomi/appinventor-sources,marksherman/appinventor-sources,josmas/app-inventor,marksherman/appinventor-sources,jisqyv/appinventor-sources,thequixotic/appinventor-sources,mit-dig/punya,puravidaapps/appinventor-sources,afmckinney/appinventor-sources,mit-dig/punya,FIRST-Tech-Challenge/appinventor-sources,CoderDojoLX/appinventor-sources,kkashi01/appinventor-sources,lizlooney/appinventor-sources,thequixotic/appinventor-sources,RachaelT/appinventor-sources,themadrobot/appinventor-sources,FIRST-Tech-Challenge/appinventor-sources,themadrobot/appinventor-sources,warren922/appinventor-sources,thequixotic/appinventor-sources,RachaelT/appinventor-sources,mit-cml/appinventor-sources,josmas/app-inventor,CoderDojoLX/appinventor-sources,CoderDojoLX/appinventor-sources,afmckinney/appinventor-sources,FIRST-Tech-Challenge/appinventor-sources,puravidaapps/appinventor-sources,ewpatton/appinventor-sources,warren922/appinventor-sources,jisqyv/appinventor-sources,FIRST-Tech-Challenge/appinventor-sources,halatmit/appinventor-sources,mit-dig/punya,ewpatton/appinventor-sources,puravidaapps/appinventor-sources,farxinu/appinventor-sources,marksherman/appinventor-sources,barreeeiroo/appinventor-sources,Klomi/appinventor-sources,kkashi01/appinventor-sources,farxinu/appinventor-sources,kkashi01/appinventor-sources,marksherman/appinventor-sources,josmas/app-inventor,halatmit/appinventor-sources,themadrobot/appinventor-sources,afmckinney/appinventor-sources,kkashi01/appinventor-sources,josmas/app-inventor,jisqyv/appinventor-sources,ewpatton/appinventor-sources,mit-cml/appinventor-sources,ewpatton/appinventor-sources,mit-cml/appinventor-sources,CoderDojoLX/appinventor-sources,barreeeiroo/appinventor-sources,marksherman/appinventor-sources,mit-cml/appinventor-sources,warren922/appinventor-sources,puravidaapps/appinventor-sources,mit-dig/punya,farxinu/appinventor-sources,barreeeiroo/appinventor-sources,RachaelT/appinventor-sources,mit-dig/punya,RachaelT/appinventor-sources,warren922/appinventor-sources,jisqyv/appinventor-sources,barreeeiroo/appinventor-sources,FIRST-Tech-Challenge/appinventor-sources,thequixotic/appinventor-sources,afmckinney/appinventor-sources,Klomi/appinventor-sources,halatmit/appinventor-sources,Klomi/appinventor-sources,warren922/appinventor-sources,josmas/app-inventor,mit-dig/punya,kkashi01/appinventor-sources,mit-cml/appinventor-sources