Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tailwind --watch randomly does not update the output CSS (Likely only when saving through SSH) #7467

Closed
windware-ono opened this issue Feb 15, 2022 · 3 comments · Fixed by #7725
Assignees

Comments

@windware-ono
Copy link

What version of Tailwind CSS are you using?

v3.0.22

What build tool (or framework if it abstracts the build tool) are you using?

Tailwind command and a pug file.

What version of Node.js are you using?

v16.14.0

What browser are you using?

N/A

What operating system are you using?

Ubuntu 20.04

Reproduction URL

tailwind.config.js

module.exports = {
	content: [],
	theme  : {
		extend: {},
	},
	plugins: [],
}

test.pug

.bg-green-100 Hello

Describe your issue

With the above 2 file setup on a remote server, I run,
tailwind --output tailwind.css --watch --content './test.pug'
it outputs the file fine and subsequently, I edit the pug file on the server locally via vim and change .bg-green-100 to .bg-green-200 and so on, the output CSS has them appended just fine.

But if I try to upload the file from my machine to the remote server through SSH (as in upload on save feature of an editor, IntelliJ to be specific) to edit the pug file, it seems the update only happens sporadically even though the tailwind command says Rebuilding... with no errors on each upload.

Perhaps it's something to do with the timing the tailwind receives the file system notification but the file isn't exactly updated right at the moment for it to pick up the change?

@windware-ono
Copy link
Author

windware-ono commented Feb 17, 2022

In cli.js of tailwind, the exact option needed called awaitWriteFinish is explicitly set as false but is there a reason for tailwind to not wait for the file to be written before processing?

I think this gets solved if this is set the same as win32. (Not sure what the optimal values are but the default of 2000ms seems too long.)

cli.js

    watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], {
      ignoreInitial: true,
      awaitWriteFinish:
        process.platform === 'win32'
          ? {
              stabilityThreshold: 50,
              pollInterval: 10,
            }
          : false,
    })

The explanation is written in this section for reference.

https://github.com/paulmillr/chokidar#performance

@windware-ono
Copy link
Author

windware-ono commented Feb 20, 2022

I've changed the above awaitWriteFinish in lib/cli.js into

{
              stabilityThreshold: 50,
              pollInterval: 10,
}

without the conditional and it's working well when uploading the watched file in content via SSH.

Relevant changes in the previous PR on Windows.

@windware-ono
Copy link
Author

windware-ono commented Oct 17, 2022

@thecrypticace

The currently defined pollInterval of 10 is way too low that it's causing excessive CPU usage.

The value was meant to be for awaitWriteFinish but it is now also used for regular watching as well having 10%+ constant CPU usage on my server.

interval: shouldPoll ? pollInterval : undefined,

Perhaps pollInterval should be around 500 which will check for changes twice a second.
With that setting, the CPU usage has dropped to 1% for the tailwind watch process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants