11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.18k stars 494 forks source link

"Unhandled rejection in promise" for watching files comes and goes (v3.0.0-alpha.5) #3219

Closed notacouch closed 8 months ago

notacouch commented 8 months ago

Operating system

Windows 11

Eleventy

3.0.0-alpha.5

Describe the bug

I'm in nearly a fresh project with the latest v3.0.0-alpha.5. I've started to get this error all of the sudden after running npx @11ty/eleventy --serve:

[11ty] Unhandled rejection in promise: (more in DEBUG output)
[11ty] UNKNOWN: unknown error, watch (via Error)
[11ty]
[11ty] Original error stack trace: Error: UNKNOWN: unknown error, watch
[11ty]     at FSWatcher._handle.onchange (node:internal/fs/watchers:207:21)

While troubleshooting, it seems the "Unhandled... (node:internal/fs/watchers:207:21)" was repeating per file that it was:

  1. passing a copy of (3 files)
  2. inside of /blog/ (2 files)

I put blog in .eleventyignore, and the error count went from 5 to 3.

The contents of my .eleventy.js:

export default function(eleventyConfig) {

  // Manage JS expectations in Liquid
  // @url https://www.11ty.dev/docs/languages/liquid/#javascript-truthiness-in-liquid
  eleventyConfig.setLiquidOptions({
    jsTruthy: true
  });

  // Default layout
  eleventyConfig.addGlobalData("layout", "_index.liquid");

  // Pass through assets
  const assets = [
    "styles.css",
    "notacouch-icon.png",
    "notacouch-icon-256.png"
  ];
  assets.forEach(function passAsset(asset) {
    eleventyConfig.addPassthroughCopy(asset);
  });
  // eleventyConfig.addPassthroughCopy("styles.css");
}

I commented out the setLiquidOptions portion, no difference. Then commented out the addGlobalData, no difference. Commented out the addPassThroughCopy inside of forEach and the error stopped. Tried running outside of a loop, it worked. Used the loop again, still worked with no error. Removed blog from .eleventyignore, still fine. Eventually, the error will come back after a while with no particular pattern.

The only thing I can think of is that I am running the project over the network from my laptop over wifi.

Next time the error comes back I'll try just removing the build artifacts (_site directory) and see if that helps before running it again.

Reproduction steps

(Not sure if anyone will be able to reproduce this, I cannot at will.)

Expected behavior

No errors once watcher starts.

Reproduction URL

No response

Screenshots

Screenshot of the error: image

notacouch commented 8 months ago

Removing the _site build did not help.

notacouch commented 8 months ago

I'm going to chalk this up to network issues. Hope this helps someone if they run into this as well.