Skip to content

npm install hangs with IO_uring thread blockages on Lightsail (Amazon Linux 2023)

0

Hi,
Whenever I try to globally install pm2 (using either with npm or yarn), the process hangs forever at the reify step. Sometimes the npm log shows an EIO error, when using /tmp as install prefix it just hangs without errors.

When I look into dmesg I see IO_uring threads (iou-sqp) getting stuck in state D, example below (if I leave it running a new entry is added every minute or so):

 [  612.392575] INFO: task iou-sqp-2052:2060 blocked for more than 122 seconds.
[  612.393399]       Not tainted 6.1.115-126.197.amzn2023.x86_64 #1
[  612.394087] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[  612.395048] task:iou-sqp-2052    state:D stack:0     pid:2060  ppid:1726   flags:0x00004000
[  612.395984] Call Trace:
[  612.396282]  <TASK>
[  612.396586]  __schedule+0x1ad/0x530
[  612.397104]  ? _raw_spin_unlock+0xa/0x30
[  612.397610]  schedule+0x5a/0xd0
[  612.398044]  schedule_preempt_disabled+0x11/0x20
[  612.398613]  __mutex_lock.constprop.0+0x372/0x6c0
[  612.399162]  io_sq_thread+0x275/0x4e0
[  612.399610]  ? membarrier_register_private_expedited+0x90/0x90
[  612.400280]  ? io_sqd_handle_event+0xd0/0xd0
[  612.400803]  ret_from_fork+0x22/0x30
[  612.401242]  </TASK>

the npm install logs show that the last step to be reify. Here is the last part of the npm log:

$ tail 2024-12-08T16_39_40_334Z-debug-0.log 
411 silly placeDep node_modules/pm2 pako@0.2.9 OK for: js-git@0.7.8 want: ^0.2.5
412 silly placeDep node_modules/pm2/node_modules/@pm2/agent lru-cache@6.0.0 OK for: semver
@7.5.4 want: ^6.0.0
413 silly fetch manifest yallist@^4.0.0
414 http fetch GET 200 https://registry.npmmirror.com/yallist 10ms (cache revalidated)
415 silly placeDep node_modules/pm2 yallist@4.0.0 OK for: lru-cache@6.0.0 want: ^4.0.0
416 silly placeDep node_modules/pm2 lodash@4.17.21 OK for: async@2.6.4 want: ^4.17.14
417 silly placeDep node_modules/pm2/node_modules/@pm2/io lru-cache@6.0.0 OK for: semver@7.
5.4 want: ^6.0.0
418 silly reify moves {}
419 verbose reify failed optional dependency /tmp/npm-global/lib/node_modules/pm2/node_mod
ules/fsevents
420 silly reify mark deleted [ '/tmp/npm-global/lib/node_modules/pm2/node_modules/fsevents
' ]

I tried a different lightsail instance, but the same thing seems to happen. Lightsail instance:

  • 2vCPU 1GB memory
  • $ uname -r 6.1.115-126.197.amzn2023.x86_64

Steps to reproduce:

sudo dnf install -y nodejs
npm install -g pm2

any thoughts?

asked 2 years ago645 views

2 Answers
0

The issue you're experiencing with npm install hanging and IO_uring thread blockages on Amazon Lightsail (Amazon Linux 2023) is likely related to a known problem with npm versions 8.x and greater. This problem can cause the npm client to hang for several minutes per dependency when a request is made to a package repository that redirects the client to Amazon S3 instead of streaming the assets directly.

To address this issue, you can try the following solutions:

  1. Use the --no-progress flag when running npm install. This can help avoid the hanging issue:

    npm install -g pm2 --no-progress
    
  2. If the above doesn't work, you can try using an earlier version of npm (version 7.x or lower) which doesn't exhibit this behavior.

  3. Another option is to increase the instance's resources, particularly the memory. Your current instance has 1GB of memory, which might not be sufficient for npm operations, especially when installing large packages globally.

  4. If the issue persists, you may want to check the disk space on your Lightsail instance. Insufficient disk space can cause npm installations to fail or hang.

  5. As a workaround, you could try using yarn instead of npm, as it might handle the package installation differently.

If none of these solutions work, the issue might be related to the underlying hardware of your Lightsail instance. In rare cases, instances can get stuck due to hardware issues. If you continue to experience problems, you may want to consider creating a new Lightsail instance or contacting AWS support for further assistance.

Remember to keep your system and npm up to date, as newer versions often include bug fixes and performance improvements that could resolve such issues.
Sources
Configure and use npm with CodeArtifact - CodeArtifact
Force stop stuck Lightsail instances - Amazon Lightsail

answered 2 years ago

0

Had the same issue on elasticbeanstalk, fixed it by changing the version of AL kernel from AL2023 to AL 2, you can see the original post here

https://repost.aws/questions/QUi024tZlhS9uWXcFUvbzRaA/npm-install-hangs-in-ec2-instance-provisioned-through-elastic-beanstalk

in my case the fix was to change the config file to use Node18 using AL2

default_platform: Node.js 18 running on 64bit Amazon Linux 2

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.