11ty / eleventy

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

Node debugger issue with 3.0.0-alpha.14 through 17 #3371

Open zachleat opened 1 month ago

zachleat commented 1 month ago

@zachleat I think the fix for this issue (https://github.com/11ty/eleventy/commit/6b8e53e516b63d7096ce06a67df6f83b15d2b9c7) broke a workflow:

Versions:

  • Node.js v20.15.1 (installed via nvm)
  • Eleventy 3.0.0-alpha.14 through 3.0.0-alpha.17
  • Google Chrome 126.0.6478.178

I try to use the Chrome DevTools for Node.js to profile my 11ty build with this command:

node --inspect-brk ./node_modules/.bin/eleventy

After connecting the debugger and resuming execution, the build hangs. When I manually pause the debugger, it's stuck here in 11ty code:

https://github.com/11ty/eleventy/blob/7128d079075e2ce308c28b163fca603e764c3c91/src/Util/Require.js#L17

Deeper into the stack, execution has stopped here:

https://github.com/nodejs/node/blob/a407d1f0b3669cc82c755700f0d500fb27cc39ea/lib/internal/modules/esm/hooks.js#L592

The stack at that point looks like

    at HooksProxy.waitForWorker (node:internal/modules/esm/hooks:592:9)
    at HooksProxy.makeSyncRequest (node:internal/modules/esm/hooks:666:10)
    at CustomizedModuleLoader.register (node:internal/modules/esm/loader:466:23)
    at ModuleLoader.register (node:internal/modules/esm/loader:331:33)
    at Function.register (node:internal/modules/esm/loader:615:35)
    at file:///home/noelle/dev/www/node_modules/@11ty/eleventy/src/Util/Require.js:17:9
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)

When I use Eleventy 3.0.0-alpha.13, the problem doesn't manifest and I can debug through the entire build without issue.

via @noelleleigh https://github.com/11ty/eleventy/issues/3270#issuecomment-2235171232

zachleat commented 1 month ago

I can confirm that it works in some versions of Node and some not:

zachleat commented 1 month ago

Confirmed removing EsmResolver fixes the issue.

zachleat commented 1 month ago

Unfortunately, this one looks out of my control. This independent MVP still fails with the same workflow:

node --inspect-brk ./registerer.js

import module from "node:module";

module.register("./empty-file.js");

console.log( "DONE!" );

Do you want to file this upstream at the Node repo or would you like me to?

zachleat commented 1 month ago

Until this is fixed upstream you can use the ELEVENTY_SKIP_ESM_RESOLVER environment variable in 3.0.0-alpha.18 or newer.

noelleleigh commented 1 month ago

Do you want to file this upstream at the Node repo or would you like me to?

You understand this problem better than I do, so you’re probably the one best equipped to file an issue.

Thanks for looking into it!