Support long-polling keep alives on the JS client

#1781