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

Pre-rendering hangs the build process #13053

Open
inssein opened this issue Feb 19, 2025 · 2 comments
Open

Pre-rendering hangs the build process #13053

inssein opened this issue Feb 19, 2025 · 2 comments
Labels

Comments

@inssein
Copy link

inssein commented Feb 19, 2025

I'm using React Router as a...

framework

Reproduction

I've had a project that started with remix, which I recently migrated to react-router. Pre-rendering has been broken for me since I tried it when I moved to 7.1, and I tried it again after 7.2, and it's still broken: mnara-solutions/utiliti.dev#64

Unfortunately, the build process just hangs without any more info. I have tried providing only a single route to ensure it's not in my pre-render logic but that didn't help either.

Additionally, I had to adjust my import of renderToReadableStream from react-dom/server to react-dom/server.browser, which I don't see documented anywhere.

System Info

System:
    OS: macOS 15.3
    CPU: (14) arm64 Apple M3 Max
    Memory: 220.17 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
  Browsers:
    Chrome: 133.0.6943.55
    Safari: 18.3
  npmPackages:
    @react-router/cloudflare: ^7.2.0 => 7.2.0
    @react-router/dev: ^7.2.0 => 7.2.0
    react-router: ^7.2.0 => 7.2.0
    vite: ^6.0.7 => 6.1.0

Used Package Manager

npm

Expected Behavior

I expect the build command to be executed successfully.

Actual Behavior

The process hangs at the end of the build process:

➜  utiliti.dev git:(feature/pre-render) ✗ npm run build

> build
> NODE_ENV=production react-router build

vite v6.1.0 building for production...
✓ 2542 modules transformed.
Generated an empty chunk: "create".
build/client/.vite/manifest.json                               23.34 kB │ gzip:  2.33 kB
build/client/assets/stackoverflow-dark-Cx-PguMy.css             1.27 kB │ gzip:  0.60 kB
build/client/assets/tailwind-DyU7gPKC.css                      51.23 kB │ gzip:  8.94 kB
build/client/assets/create-l0sNRNKZ.js                          0.00 kB │ gzip:  0.02 kB
build/client/assets/convert-text-file-DJUzPpLu.js               0.11 kB │ gzip:  0.12 kB
build/client/assets/use-isomorphic-layout-effect-2c42DOkn.js    0.12 kB │ gzip:  0.13 kB
build/client/assets/meta-DIElYQO9.js                            0.18 kB │ gzip:  0.14 kB
build/client/assets/button-DcuqW6vU.js                          0.34 kB │ gzip:  0.27 kB
build/client/assets/number-input-DZbDzB0i.js                    0.36 kB │ gzip:  0.27 kB
build/client/assets/simple-output-BYcvYxBL.js                   0.40 kB │ gzip:  0.28 kB
build/client/assets/read-only-textarea-DET3cJ2O.js              0.43 kB │ gzip:  0.33 kB
build/client/assets/dropdown-D3yZNh9K.js                        0.52 kB │ gzip:  0.35 kB
build/client/assets/MagnifyingGlassIcon-BsCVPdbu.js             0.54 kB │ gzip:  0.39 kB
build/client/assets/use-local-storage-DpI-rBck.js               0.55 kB │ gzip:  0.36 kB
build/client/assets/ArrowLeftIcon-DwnJrsqm.js                   0.59 kB │ gzip:  0.41 kB
build/client/assets/icon-button-CBRrVueT.js                     0.62 kB │ gzip:  0.39 kB
build/client/assets/use-hydrated-4Kqb_AE9.js                    0.69 kB │ gzip:  0.47 kB
build/client/assets/index-BFTMnjod.js                           0.79 kB │ gzip:  0.53 kB
build/client/assets/checkbox-B33403AD.js                        0.90 kB │ gzip:  0.47 kB
build/client/assets/index-CpXKBTBY.js                           0.91 kB │ gzip:  0.51 kB
build/client/assets/layout-5ML8qZ8z.js                          1.04 kB │ gzip:  0.59 kB
build/client/assets/box-COFKvEvu.js                             1.12 kB │ gzip:  0.44 kB
build/client/assets/read-file-oVWGX_bV.js                       1.25 kB │ gzip:  0.81 kB
build/client/assets/aes-Bj6qpX1Y.js                             1.32 kB │ gzip:  0.75 kB
build/client/assets/utiliti-ByJwoYeB.js                         1.41 kB │ gzip:  0.75 kB
build/client/assets/content-wrapper-D-meDMf3.js                 1.60 kB │ gzip:  0.75 kB
build/client/assets/copy-3pRH-mRj.js                            1.84 kB │ gzip:  0.99 kB
build/client/assets/cuid-CNOgEfUN.js                            2.03 kB │ gzip:  1.00 kB
build/client/assets/utilities-BuKWQYs9.js                       2.34 kB │ gzip:  1.08 kB
build/client/assets/index-DpehTMXh.js                           2.65 kB │ gzip:  1.32 kB
build/client/assets/password-generator-K6Di2oda.js              2.97 kB │ gzip:  1.39 kB
build/client/assets/read-CUf43Fzd.js                            3.16 kB │ gzip:  1.43 kB
build/client/assets/ns-lookup-B1MGU17T.js                       3.34 kB │ gzip:  1.42 kB
build/client/assets/whois-D2Qm9nHZ.js                           3.87 kB │ gzip:  1.69 kB
build/client/assets/index-D1jatSMv.js                           3.92 kB │ gzip:  1.54 kB
build/client/assets/lorem-ipsum-CetD_upI.js                     4.08 kB │ gzip:  1.97 kB
build/client/assets/hashing-05fSGuQs.js                         4.70 kB │ gzip:  2.08 kB
build/client/assets/json-fz1WGH8m.js                            4.75 kB │ gzip:  2.03 kB
build/client/assets/dataurl-B96PRtSa.js                         4.80 kB │ gzip:  2.30 kB
build/client/assets/url-fH4UuOzx.js                             5.08 kB │ gzip:  2.04 kB
build/client/assets/uuid-CF5N5T8Y.js                            6.01 kB │ gzip:  2.55 kB
build/client/assets/convert-image-file-DtxHnUM0.js              8.92 kB │ gzip:  3.30 kB
build/client/assets/index-B0YDkp51.js                          11.26 kB │ gzip:  4.57 kB
build/client/assets/base64-DmXM8qwS.js                         12.12 kB │ gzip:  5.55 kB
build/client/assets/word-counter-CowxjIvF.js                   13.41 kB │ gzip:  5.20 kB
build/client/assets/transition-CJoS8xpa.js                     14.96 kB │ gzip:  5.84 kB
build/client/assets/common-onpKa1Wt.js                         20.78 kB │ gzip:  8.12 kB
build/client/assets/qr-code-DfwGU98A.js                        23.30 kB │ gzip:  9.10 kB
build/client/assets/tooltip-HYFeb3uA.js                        28.87 kB │ gzip: 10.52 kB
build/client/assets/unix-timestamp-BvIETa8U.js                 29.14 kB │ gzip:  8.88 kB
build/client/assets/code-BK1E5QhO.js                           47.20 kB │ gzip: 17.88 kB
build/client/assets/json-viewer-YIgRKUf8.js                    62.36 kB │ gzip: 22.03 kB
build/client/assets/markdown-to-html-DH4kPQze.js               65.33 kB │ gzip: 22.31 kB
build/client/assets/routes-DLbOHaFQ.js                         85.95 kB │ gzip: 19.75 kB
build/client/assets/image-converter-BMPV43IC.js               103.37 kB │ gzip: 32.59 kB
build/client/assets/chunk-HA7DTUK3-Bv1ZaYQK.js                109.19 kB │ gzip: 36.93 kB
build/client/assets/root-DOtebZ16.js                          168.40 kB │ gzip: 56.18 kB
build/client/assets/entry.client-DTQ4uIB-.js                  175.75 kB │ gzip: 56.04 kB
build/client/assets/sql-formatter-BYY2Ktyq.js                 235.31 kB │ gzip: 59.81 kB
✓ built in 2.87s
vite v6.1.0 building SSR bundle for production...
"default" is imported from external module "react" but never used in "virtual:react-router/with-props", "app/routes/hashing.tsx", "app/routes/url.tsx", "app/routes/uuid.tsx", "app/routes/cuid.tsx", "app/routes/sql-formatter.tsx", "app/components/utiliti.tsx", "app/routes/dataurl.tsx", "app/routes/base64.tsx", "app/components/number-input.tsx", "app/components/dropdown.tsx", "app/components/read-file.tsx", "app/routes/unix-timestamp.tsx", "app/components/json-viewer.tsx", "app/components/shadow-dom.tsx", "app/routes/markdown-to-html.tsx", "app/components/read-only-textarea.tsx", "app/routes/password-generator.tsx", "app/hooks/use-local-storage.ts", "app/routes/private-note/index.tsx", "app/hooks/use-isomorphic-layout-effect.ts", "app/routes/lorem-ipsum.tsx", "app/components/icon-button.tsx", "app/routes/qr-code.tsx", "app/hooks/use-hydrated.ts", "app/routes/private-note/read.tsx", "app/components/tooltip.tsx", "app/routes/word-counter.tsx", "app/components/copy.tsx", "app/routes/json.tsx", "app/routes/image-converter.tsx", "app/components/popular-utilities.tsx", "app/components/search.tsx", "app/hooks/use-keyboard-shortcut.ts" and "app/components/layout.tsx".
✓ 67 modules transformed.
build/server/.vite/manifest.json                       0.73 kB
build/server/assets/stackoverflow-dark-Cx-PguMy.css    1.27 kB
build/server/assets/tailwind-DyU7gPKC.css             51.23 kB
build/server/index.js                                248.11 kB
Prerender (html): /private-note/ -> build/client/private-note/index.html
Prerender (html): /json -> build/client/json/index.html
Prerender (html): /base64 -> build/client/base64/index.html
Prerender (html): /url -> build/client/url/index.html
Prerender (html): /dataurl -> build/client/dataurl/index.html
Prerender (html): /image-converter -> build/client/image-converter/index.html
Prerender (html): /word-counter -> build/client/word-counter/index.html
Prerender (html): /markdown-to-html -> build/client/markdown-to-html/index.html
Prerender (html): /lorem-ipsum -> build/client/lorem-ipsum/index.html
Prerender (html): /password-generator -> build/client/password-generator/index.html
Prerender (html): /uuid -> build/client/uuid/index.html
Prerender (html): /cuid -> build/client/cuid/index.html
Prerender (html): /ns-lookup -> build/client/ns-lookup/index.html
Prerender (html): /whois -> build/client/whois/index.html
Prerender (html): /unix-timestamp -> build/client/unix-timestamp/index.html
Prerender (html): /sql-formatter -> build/client/sql-formatter/index.html
Prerender (html): /qr-code -> build/client/qr-code/index.html
Prerender (html): /hashing -> build/client/hashing/index.html
✓ built in 646ms
@inssein inssein added the bug label Feb 19, 2025
@brophdawg11
Copy link
Contributor

This doesn't hang for me but fails due to too many open files when trying to load your server build.

I added a debug log right before that to confirm that's what it fails on.

You could try using ulimit to increase the limit potentially?

build/client/assets/root-BeCdkc-D.js                          168.12 kB │ gzip: 56.11 kB
build/client/assets/entry.client-CcCvXKpG.js                  175.65 kB │ gzip: 55.98 kB
build/client/assets/sql-formatter-DRUD8jBg.js                 235.33 kB │ gzip: 59.82 kB
✓ built in 3.79s
vite v6.0.11 building SSR bundle for production...
"default" is imported from external module "react" but never used in "virtual:react-router/with-props", "app/routes/base64.tsx", "app/routes/hashing.tsx", "app/routes/uuid.tsx", "app/routes/cuid.tsx", "app/routes/sql-formatter.tsx", "app/components/dropdown.tsx", "app/routes/unix-timestamp.tsx", "app/components/utiliti.tsx", "app/routes/url.tsx", "app/components/read-file.tsx", "app/components/json-viewer.tsx", "app/routes/private-note/index.tsx", "app/routes/image-converter.tsx", "app/components/copy.tsx", "app/routes/json.tsx", "app/components/tooltip.tsx", "app/routes/lorem-ipsum.tsx", "app/components/read-only-textarea.tsx", "app/components/number-input.tsx", "app/routes/password-generator.tsx", "app/components/shadow-dom.tsx", "app/routes/markdown-to-html.tsx", "app/hooks/use-local-storage.ts", "app/routes/word-counter.tsx", "app/hooks/use-isomorphic-layout-effect.ts", "app/hooks/use-hydrated.ts", "app/routes/private-note/read.tsx", "app/routes/dataurl.tsx", "app/components/icon-button.tsx", "app/routes/qr-code.tsx", "app/components/popular-utilities.tsx", "app/hooks/use-keyboard-shortcut.ts", "app/components/search.tsx" and "app/components/layout.tsx".
✓ 67 modules transformed.
build/server/.vite/manifest.json                       0.84 kB
build/server/assets/stackoverflow-dark-Cx-PguMy.css    1.27 kB
build/server/assets/tailwind-DyU7gPKC.css             51.23 kB
build/server/index.js                                245.58 kB
importing  file:///.../utiliti.dev/build/server/index.js     ⚠️ <-- debugging log added by me
x Build failed in 370ms
[react-router] EMFILE: too many open files, open '/.../utiliti.dev/node_modules/jszip/lib/index.js'
    at Object.openSync (node:fs:561:18)
    at readFileSync (node:fs:445:35)
    at getSourceSync (node:internal/modules/esm/load:68:14)
    at getSource (node:internal/modules/esm/translators:65:10)
    at createCJSModuleWrap (node:internal/modules/esm/translators:181:32)
    at ModuleLoader.commonjsStrategy (node:internal/modules/esm/translators:272:10)
    at ModuleLoader.#translate (node:internal/modules/esm/loader:437:12)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:484:27) {
  errno: -24,
  code: 'PLUGIN_ERROR',
  syscall: 'open',
  path: '/.../utiliti.dev/node_modules/jszip/lib/index.js',
  pluginCode: 'EMFILE',
  plugin: 'react-router',
  hook: 'writeBundle'
}

@inssein
Copy link
Author

inssein commented Feb 19, 2025

I changed my session ulimit and had no luck, haven't tried changing it system-wide. Additionally, this doesn't fail just for me; it also fails in CI when Cloudflare tries to build the project with: "Failed: build exceeded the time limit and was terminated.".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants