stylelint: Fix hang inside Docker

What minimal example or steps are needed to reproduce the bug?

For reasons that are beyond the scope of this issue, I am looking to Docker-ise Stylelint and some configuration. It seems running it in inside Docker hangs when you point it to a valid docker path.

Dockerfile

FROM node:20-alpine3.17

RUN npm install -g stylelint stylelint-config-standard

Then running & accessing the docker container:

docker run -it --rm -v $(pwd):/app scss-stylelint-dev "/bin/sh"

Then running stylelint inside the container

stylelint app/**/*.css --config-basedir /usr/local/lib/node_modules/

Running this on my computer is near-instant, but inside the docker container this hangs for a long time - sometimes it is successful, other times not.

I am 100% happy to blame this on my dockering skills, but I’ve tried everything I can think of (yarn, instakling in different places etc)

What minimal configuration is needed to reproduce the bug?

{
  "extends": "/usr/local/lib/node_modules/stylelint-config-standard"
}

How did you run Stylelint?

stylelint app/**/*.css --config-basedir /usr/local/lib/node_modules/

Which Stylelint-related dependencies are you using?

  • stylelint@^13.0.0
  • stylelint-config-standard@^34.0.0

What did you expect to happen?

It to lint the CSS

What actually happened?

It hangs when given a valid path. If the glob path is invalid, it exists quickly

Do you have a proposal to fix the bug?

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Thanks again for all your assistance @jeddy3 and @romainmenke. It was hugely appreciated and although, I was wasting your time you made me feel like I wasn’t 😄

This is all for CI purposes and in order to push it, it needed to be made with a slightly different platform (Mac M1 going to Debian Intel). Because of this, I was building and running the image with the --platform attributes. Removing this and building a slightly more optimised docker image has got this down further (and looks similar to your experience)

So ultimately everything was my fault. Sorry!

TL:DR;

  • Make sure you are up-to-date with (at time of writing) Version 15
  • Build the docker image for your platform
  • If you wish to debug, put node --cpu-prof in front of your command

Thanks again 😃

This is caused by the formatter.

Screenshot 2023-07-05 at 13 27 20

I suspect this tries to determine the width of the output terminal? I can imagine that this extremely slow for Dockerized workloads.

Setting a different formatter should make it fast again : --formatter unix

https://stylelint.io/user-guide/options/#formatter

Upgrading stylelint has dropped it down to 6 seconds

It’s great to know that all our performance work in 14.x and 15.x has born fruit.

There is already a second of work being done with only loading Stylelint and its dependencies. This is a lot longer than it should take and a good indication that the problem is not with Stylelint.

I think we can close the issue then.

@mikestreety If you do find the root cause, you’re welcome to share it here as it may benefit someone else.

One thing I have got is a slightly outdated version - I’m running 13 (latest is 15) and stylelint-scss is 3 (latest 5). I’ll try upgrading and see if that makes any difference

Yes, please upgrade. The last 13.x release was over 2 years ago. There have been many releases since then.

@romainmenke

  • My local system is Mac (Ventura 13.4)
  • No fixes are applied unless --fix is appended