11ty / eleventy-dev-server

A minimal generic web-development web server.
103 stars 19 forks source link

Occasional error in morphdom-esm when saving changes #21

Closed andy-bond closed 2 years ago

andy-bond commented 2 years ago

Describe the bug I'm having trouble reproducing this, but this does occur fairly consistently in a project I'm working on when serving eleventy.

Essentially, I make some changes to a file and the elevent-dev-server tries to reload. It sometimes encounters the error below. If I save the file again, it will continue working normally.

I am running this via an Nx monorepo using the @nrwl/workspace:run-commands, so not sure if that affects anything. The equivalent command using npm-run-all would be the command here.

[11ty] Unhandled rejection in promise: (more in DEBUG output)
[11ty] ENOENT: no such file or directory, open '/Users/bondandy/Projects/cx-cloud-ui/node_modules/@11ty/eleventy-dev-server/node_modules/morphdom/dist/morphdom-esm.js' (via Error)
[11ty] 
[11ty] Original error stack trace: Error: ENOENT: no such file or directory, open '/Users/bondandy/Projects/cx-cloud-ui/node_modules/@11ty/eleventy-dev-server/node_modules/morphdom/dist/morphdom-esm.js'
[11ty]     at Object.openSync (node:fs:585:3)
[11ty]     at Object.readFileSync (node:fs:453:35)
[11ty]     at EleventyDevServer._getFileContents (/Users/bondandy/Projects/cx-cloud-ui/node_modules/@11ty/eleventy-dev-server/server.js:184:23)
[11ty]     at EleventyDevServer.requestMiddleware (/Users/bondandy/Projects/cx-cloud-ui/node_modules/@11ty/eleventy-dev-server/server.js:275:29)
[11ty]     at EleventyDevServer.onRequestHandler (/Users/bondandy/Projects/cx-cloud-ui/node_modules/@11ty/eleventy-dev-server/server.js:347:11)
[11ty]     at Server.emit (node:events:390:28)
[11ty]     at parserOnIncoming (node:_http_server:951:12)
[11ty]     at HTTPParser.parserOnHeadersComplete (node:_http_common:128:17)

To Reproduce Steps to reproduce the behavior:

  1. Save changes
  2. Error occurs
  3. Save same page again
  4. Works normal

Expected behavior Ideally no error occurs and the changes are saved & page reloads

Environment:

Additional context Add any other context about the problem here.

zachleat commented 2 years ago

Until this gets some triage, just want to note that you can disable morphdom specifically with domdiff: false https://www.11ty.dev/docs/watch-serve/#eleventy-dev-server

andy-bond commented 2 years ago

That is super helpful - thanks @zachleat!

This is a great workaround for now! Sorry for not putting this in the right repo - I always assume things bundled with 11ty are in the main 11ty repo.

zachleat commented 2 years ago

(no worries at all!)

zachleat commented 2 years ago

I did make a slight modification to this code in 1.0.0-canary.8 of dev server, please retest after that release!

zachleat commented 2 years ago

1.0.0-canary.8 (and dare I say canary 9) are out

andy-bond commented 2 years ago

Thanks @zachleat - I updated to 2.0.0-canary.5 and cannot get this to occur any longer.

BTW - is there anywhere that lists what changes between canary/beta builds? I like to use the latest & greatest but its hard to tell what I am gaining by switching canary version unless I see a Tweet or you comment on a bug fix. Not really a complaint, just curious if a changelog existed that tracked this kind of thing :)

zachleat commented 2 years ago

@andy-bond the best way is to look at the Milestone (newest stuff is on top) https://github.com/11ty/eleventy/milestone/38?closed=1

Thanks!