Gatsby: Development crashing due to temporary files

Created on 5 Oct 2017  路  6Comments  路  Source: gatsbyjs/gatsby

I'm developing with emacs and by default it creates lockfiles with the name of the file being edited prepended with .#. When I save the file the lockfile is removed and this causes the server to crash with the following error:

error ENOENT: no such file or directory, open 'c:\Users\admin\Documents....\src\layouts.#index.js'

All 6 comments

Same here, I'm using IntelliJ which creates temporary files ending in ___jb_tmp___ which gatbsy develop doesn't like:

info added file at src/components/Bio/index.js___jb_tmp___
error ENOENT: no such file or directory, open 'src/components/Bio/index.js___jb_tmp___'


  Error: ENOENT: no such file or directory, open 'src/components/Bio/index.js___jb_tmp___'

info changed file at src/components/Bio/index.js
 WAIT  Compiling...                                                                                                                                                                                        09:53:54

info file deleted at src/components/Bio/index.js___jb_tmp___
error UNHANDLED EXCEPTION


  TypeError: Cannot read property 'id' of undefined

  - gatsby-node.js:72 FSWatcher.<anonymous>
    [nl]/[gatsby-source-filesystem]/gatsby-node.js:72:21

  - index.js:181 FSWatcher.<anonymous>
    [nl]/[chokidar]/index.js:181:21

  - Array.forEach

  - index.js:180 FSWatcher.<anonymous>
    [nl]/[chokidar]/index.js:180:43

For now I've been developing with

$ while true; do gatsby develop && break; done

But it's still a bit tedious to wait for gatsby to restart the development server (almost) every edit.

Is there a solution? Maybe an exclude option in the gatsby-config?

Thanks!

I wonder if we should just hardcode excludes for things like this?

The file watcher is created here: https://github.com/gatsbyjs/gatsby/blob/78ad5b2c613b442d35239987d6c5e3892c54377e/packages/gatsby/src/commands/develop.js#L226

Chokidar has an ignored option, so the change might be something like:

const ignored = [/.*___jb_tmp___$/]
chokidar.watch(watchGlobs, { ignored }).on(`change`, async () => {
// code continues...

Although that doesn't handle the emacs case above. Maybe there should be a default list and the option to configure it?

gatsby-source-filesystem shouldn't be erroring like that. Instead of whack-a-mole ignoring stuff like this, let's figure out why it's erroring and fix that.

Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help!

[Solved]

Turns out that those aren't auto-saved temp files, but rather symbolic link files.

If you're using Emacs and those .# files trouble your development flow, try this option in your init.el (Emacs configuration file):

(setq create-lockfiles nil)

This will disable the creation of symlink files.

References:

If you're using Emacs and those .# files trouble your development flow, try this option in your init.el (Emacs configuration file):

(setq create-lockfiles nil)

A slightly less invasive approach is to only enable it for the current project root and its subdirectories as per https://github.com/facebook/create-react-app/issues/9056#issuecomment-683354754

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mikestopcontinues picture mikestopcontinues  路  3Comments

theduke picture theduke  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

brandonmp picture brandonmp  路  3Comments