<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Syntax error: Unterminated statement error after running a loop for a long time]]></title><description><![CDATA[<p dir="auto">I have set up 10 Flic Hubs to run a code that sends a ping to my API. The code runs in an infinite loop with 1 hour sleep so I've had a ping every hour from every device.</p>
<p dir="auto">All seemed perfect until all of the devices stopped working around the same time.</p>
<p dir="auto">I've got below error on the SDK:</p>
<pre><code>SyntaxError: unterminated statement (line 2)
    at [anon] (root/heartbeat/main.js:2) internal
    at [anon] (duktape.c:71822) internal
    at loadAndCompileUserModule () native strict preventsyield
    at require (init.js:122)
    at [anon] (init.js:139) preventsyield
    at runInit () native strict preventsyield
    at handlePacket (pipe_communication.js:48)
    at readCallback (pipe_communication.js:93) preventsyield
</code></pre>
<p dir="auto">Line to corresponds to either of below lines:</p>
<pre><code>var buttonManager = require("buttons");
var buttons = buttonManager.getButtons();
</code></pre>
<p dir="auto">Here is how my code looks like:</p>
<pre><code>// Heartbeat.js
var buttonManager = require("buttons");
var buttons = buttonManager.getButtons();
var http = require("http");

var url = "my_api_url";
var DEVICE_ID = 'hub_id'

function myLoop() {
    setTimeout(function() {
        for (var i = 0; i &lt; buttons.length; i++) {
            var button = buttons[i];
            http.makeRequest({
                url: url,
                method: "POST",
                headers: {
                    "Content-Type": "application/json"
                },
                content: JSON.stringify({
                    'pressedAt': Date.now(),
                    'batteryStatus': button.batteryStatus,
                    'button_sn': button.serialNumber,
                    'activeDisconnect': button.activeDisconnect,
                    'connected': button.connected,
                    'batteryStatus': button.batteryStatus,
                    'uuid': button.uuid,
                    'flicVersion': button.flicVersion,
                    'firmwareVersion': button.firmwareVersion,
                    'key': button.key,
                    'passiveMode': button.passiveMode,
                    'device_sn': DEVICE_ID,
                    'dataType': 'heartbeat'
                }),
            }, function(err, res) {
                console.log("request status: " + JSON.stringify(res));
            });
        }

        myLoop();
    }, 1000 * 60 * 60)
}

myLoop();
console.log("Started");
</code></pre>
<p dir="auto">Anyone have any ideas?<br />
Thanks.</p>
]]></description><link>https://community.flic.io/topic/18084/syntax-error-unterminated-statement-error-after-running-a-loop-for-a-long-time</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 19:39:44 GMT</lastBuildDate><atom:link href="https://community.flic.io/topic/18084.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Sep 2021 11:48:57 GMT</pubDate><ttl>60</ttl></channel></rss>