Skip to content

raspberry pi 300% cpu setTimeout() #49937

@brubbel

Description

@brubbel

Version

v20.7.0

Platform

5.15.61-v7l+ #1579 SMP armv7l GNU/Linux

Subsystem

What steps will reproduce the bug?

The following 3-line script causes high cpu on a raspberry pi4 /CM4 (actively tested on 2 devices, seen on more).
After restarting nodejs a couple of times the issue disappears (the device must be rebooted to consistently get the 300% cpu usage again). Both setInterval and setTimeout show the same behaviour.
After 4-5 minutes, cpu usage drops to normal levels again, until reboot that is.

setInterval(() => {
  console.log('test');
}, 20000);

Interval works correctly: 'test' is printed every x seconds

The issue is also present in the following nodejs versions, so it must have been introduced around 18.18.0.
20.7.0 bug
18.18.0 bug
18.17.1 OK!
18.17.0 OK!
18.16.0 OK!
18.14.0: OK!
18.0.0: OK!
16.20.2: OK!

The issue was detected both in a docker container and running nodejs without docker.
Tested both with .deb install and the unoffical builds.
Dockerfile is below.

Dockerfile:

FROM debian:bullseye-slim

WORKDIR /tmp/

RUN set -ex
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
RUN apt-get -y update

RUN apt-get -y --no-install-recommends install ca-certificates
RUN apt-get -y --no-install-recommends install curl
RUN apt-get -y --no-install-recommends install gnupg
RUN apt-get -y --no-install-recommends install libatomic1

RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get -y update
RUN apt-get -y --no-install-recommends install nodejs

CMD ["/bin/bash"]

How often does it reproduce? Is there a required condition?

Always after reboot. Starting from versions v18.18.0 up to v20.7.0
Never seen on my desktop, always on RPI devices (rpi4 / CM4)

What is the expected behavior? Why is that the expected behavior?

0% cpu usage, just as in version 16.x

What do you see instead?

300% cpu usage (top -c -H to show threads)

 1083 root      20   0  127644  32736  29248 R  99.9   0.4   2:26.74 node bootservertcprelay.js                                            
 1085 root      20   0  127644  32736  29248 R  99.9   0.4   2:26.61 node bootservertcprelay.js                                            
 1090 root      20   0  127644  32736  29248 R  99.9   0.4   2:26.62 node bootservertcprelay.js 

Additional information

Seen also, but very rarely on nodejs version 16.x, so can't confirm it is the same issue.
Please take note that rpi is running a 32-bit kernel...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions