01-09-2022 22:12
01-09-2022 22:12
Whilst using console.log to list a small array of strings it does not always produce the entire array.
// max 300 items
for ( i = 0; i < array.length; i++ ) {
console.log( i + array[i] );
}
Sometimes it stops short of the total, sometimes some elements are missing, or both.
Is this erractic behviour related to the OS simulator 0.92, network issues or a bug?
Or is there a good way to ensure the full list is shown each time?
Author | ch, passion for improvement.
01-09-2022 23:37
01-09-2022 23:37
My theory is that the debug bridge gets saturated. I reckon it's good for about 30 lines of text in quick succession, after which lines get dropped until it catches up. If you can't print less, print more slowly (ie, introduce delays).
01-09-2022 23:50
01-10-2022 00:04
01-10-2022 00:04
Alas, not with me (I'm a long way from home ATM). From memory(!!), I used a setInterval loop, which has the advantage of letting the operating system do its thing while your program waits. If you try to create a delay by hogging the CPU, the system's message queue can overflow (which may be what you observed).
01-10-2022 01:48
01-10-2022 01:48
@Gondwana- thanks, will try that instead of
// max 300 items
for ( i = 0; i < array.length; i++ ) {
sleep(500).then(() => {
console.log( i + array[i] );
});
}
// sleep time expects milliseconds
function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
Author | ch, passion for improvement.
01-11-2022 10:18
01-11-2022 10:18
Of course the SetInterval() way works but this gets to be very problematic.
Is there anything that can be done to stop console.log messages disappearing whilst keeping them in sync with activity on the watch face?
It makes debugging rather difficult when you don't get to see all the messages, every time. The success can be quite sporadic.
There must be some underlying issue that needs resolving so that messages aren't ever lost?
Author | ch, passion for improvement.
01-11-2022 11:30
01-11-2022 11:30
You could try a subset of this approach (ie, write debugging lines to storage).
01-12-2022 21:12
01-12-2022 21:12
thanks @Gondwana - that can be useful but for ensuring simple console.log messages appear consistently is there some way of modifying the environment?
@JonFitbit- do you have an idea what causes log messages to stop appearing or be skipped in the console? Can it be a user network issue?
Also what is the maximum size of one console.log string?
Author | ch, passion for improvement.