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

feat(gatsby-source-filesystem): Expose usePolling option #36975

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

markphilpot
Copy link

@markphilpot markphilpot commented Nov 7, 2022

Description

In scenarios where the use of file system polling is necessary (network file systems, hard links, etc).

Relevant chokidar option description here -- https://github.com/paulmillr/chokidar#performance

Documentation

Related Issues

Fixes #36877

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Nov 7, 2022
@markphilpot
Copy link
Author

The plugin README needs to be updated -- If you have any guidance on how you want to incorporate it, I can take a shot at it.

@LekoArts LekoArts added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Nov 16, 2022
@LekoArts LekoArts self-assigned this Nov 16, 2022
@LekoArts
Copy link
Contributor

LekoArts commented Nov 16, 2022

Is the CHOKIDAR_USEPOLLING environment variable not working for you?

You may also set the CHOKIDAR_USEPOLLING env variable to true (1) or false (0) in order to override this option.

@LekoArts
Copy link
Contributor

The plugin README needs to be updated -- If you have any guidance on how you want to incorporate it, I can take a shot at it.

The https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-source-filesystem#options section could use a little revamp.

  • Add h3 headings for each option
  • Below a little paragraph explaining it

@LekoArts LekoArts changed the title Expose usePolling option to source-filesystem feat(gatsby-source-filesystem): Expose usePolling option Nov 16, 2022
@markphilpot
Copy link
Author

Is the CHOKIDAR_USEPOLLING environment variable not working for you?

You may also set the CHOKIDAR_USEPOLLING env variable to true (1) or false (0) in order to override this option.

I could not get it to work. Both from the command line and explicitly in package.json, using CHOKIDAR_USEPOLLING=1 gatsby devleop in any combination I tried didn't trigger polling to be used.

In scenarios where the use of file system polling is necessary (network
file systems, hard links, etc)
@markphilpot markphilpot force-pushed the source-filesystem-polling-option branch from 75fb1b1 to 47db9e9 Compare November 16, 2022 17:02
@LekoArts
Copy link
Contributor

It works for me CHOKIDAR_USEPOLLING=1 yarn develop 🤷

image

I'd also be surprised to not have https://github.com/paulmillr/chokidar/blob/0f163b89f3ae76607900aa48fec9fa3fdefd7ca1/index.js#L341 working - so with this in mind I'm actually inclined to not add the option at all. Better to not give people the option (less footguns).

We should update the readme tho (which e.g. could point out the env var)

@markphilpot
Copy link
Author

I found the issue:

When you use the options parameter in chokidar, setting usePolling to true also sets useFsEvents to false, but only on macOS.

CleanShot 2022-11-17 at 13 10 45@2x

If you just use the environment variable, both usePolling and useFsEvents are set to true, and you don't get the desired behavior (let's set aside this side effect behavior is not great). I confirmed that to correctly handle my original hard link issue, I need chokidar running with usePolling as true and useFsEvents as false.

It doesn't seem like setting useFsEvents is exposed via an environment variable override.

I'm not sure what the best course of action here is since you need to understand the behavior of an internal library to understand what to do (not to mention the wierd macOS only side effect behavior).

I could try submitting a PR to chokidar to expose a CHOKIDAR_USEFSEVENTS env parameter I guess...

@LekoArts
Copy link
Contributor

Yeah, I fear this is out of our hands then. Best course of action then is to open an issue with them to fix this behavior. Either by introducing a new environment variable or moving the code around so that usePolling is set with the env var before the fsEvents check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gatsby develop not reflecting changes in textbundle files when written via mac application
3 participants