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

Netlify briefly broke esbuild builds, causing "Dynamic require of "X"" errors for every serverless rendered page [fixed] #4079

Closed
swyxio opened this issue Feb 23, 2022 · 13 comments

Comments

@swyxio
Copy link
Contributor

swyxio commented Feb 23, 2022

Describe the bug

as part of regular maintenance for swyxkit i upgraded the deps as per the title

and now everything is throwing a 500 error with this Dynamic require of "fs" error, even though i'm pretty darn sure I don't actually write that code. EDIT: Possible related error: #2400

this error only happens in prod build, not in local dev. is this something broken in the netlify adapter?

Feb 23, 07:43:09 PM: 24d25a60 ERROR  Error: Dynamic require of "fs" is not supported
Feb 23, 07:43:09 PM: 24d25a60     at __require (file:///var/task/.netlify/functions-internal/render.js:28:9)
Feb 23, 07:43:09 PM: 24d25a60     at node_modules/gray-matter/index.js (file:///var/task/.netlify/functions-internal/render.js:10725:14)
Feb 23, 07:43:09 PM: 24d25a60     at __require2 (file:///var/task/.netlify/functions-internal/render.js:34:44)
Feb 23, 07:43:09 PM: 24d25a60     at .netlify/server/chunks/content-4d53413a.js (file:///var/task/.netlify/functions-internal/render.js:17141:37)
Feb 23, 07:43:09 PM: 24d25a60     at __init (file:///var/task/.netlify/functions-internal/render.js:31:50)
Feb 23, 07:43:09 PM: 24d25a60     at .netlify/server/entries/endpoints/api/listContent.json.js (file:///var/task/.netlify/functions-internal/render.js:17185:5)
Feb 23, 07:43:09 PM: 24d25a60     at __init (file:///var/task/.netlify/functions-internal/render.js:31:50)
Feb 23, 07:43:09 PM: 24d25a60     at file:///var/task/.netlify/functions-internal/render.js:26540:51
Feb 23, 07:43:09 PM: 24d25a60     at async resolve (file:///var/task/.netlify/functions-internal/render.js:26295:83)
Feb 23, 07:43:09 PM: 24d25a60     at async respond (file:///var/task/.netlify/functions-internal/render.js:26246:22)

image

Reproduction

this is the netlify build logs https://app.netlify.com/sites/swyxkit/deploys/621638d27781070008fb992c

and this is the commit https://github.com/sw-yx/swyxkit/tree/c452df95219f73c4c3cd199490752656f0ab89ec

Logs

No response

System Info

System:
    OS: macOS 11.3.1
    CPU: (8) x64 Apple M1
    Memory: 38.87 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.11.1 - /var/folders/h_/1lq46tdj7jdbs0j1m5l6rlb00000gn/T/fnm_multishell_23513_1645623105494/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 8.0.0 - /var/folders/h_/1lq46tdj7jdbs0j1m5l6rlb00000gn/T/fnm_multishell_23513_1645623105494/bin/npm
  Browsers:
    Chrome: 98.0.4758.102
    Firefox: 94.0.2
    Safari: 14.1
  npmPackages:
    @sveltejs/adapter-netlify: ^1.0.0-next.46 => 1.0.0-next.46 
    @sveltejs/kit: ^1.0.0-next.283 => 1.0.0-next.283 
    svelte: ^3.44.3 => 3.46.4

Severity

blocking an upgrade

Additional Information

still trying to narrow down the precise version where this broke

@swyxio
Copy link
Contributor Author

swyxio commented Feb 23, 2022

currently suspect this issue is related to SvelteKit 279->280 where there was an important breaking change

#4034


nope.. 500 errors still happen with Kit 279 and Netlify Adapter 44: https://62163c6047aa970007eba63f--swyxkit.netlify.app/blog

continuing to go back in versions.


kit 270 and netlify 44 still has the error https://62163d105d832f0008263fe6--swyxkit.netlify.app/blog


even kit 261 has the error https://62163d98e3c77e0007668c18--swyxkit.netlify.app/blog

this is bad.. this means something broke in 260->261 and I don't understand why.

@swyxio swyxio changed the title Upgrading from SvelteKit 260 to 283 starts returning 500 for every page Upgrading from SvelteKit v260 to v261+ starts returning 500 for every page Feb 23, 2022
@swyxio
Copy link
Contributor Author

swyxio commented Feb 23, 2022

i realized that my last working build on Feb 16 had Netlify adapter 45 and Kit 269 so i tried to repro that.

somehow, it still doesn't work.

i just found #2400 and trying their rm -rf node_modules package-lock.json && npm i. i realized that it was also installing later versions than i intended so i had to pin the verison.


it still does not work: https://6216421075c7d30007e80be8--swyxkit.netlify.app/blog

i am quite at a loss as to what to do. this error just keeps happening.

@swyxio swyxio changed the title Upgrading from SvelteKit v260 to v261+ starts returning 500 for every page Upgrading from SvelteKit v260 to v261+ starts returning 500 errors "Dynamic require of "X"" for every page Feb 23, 2022
@swyxio swyxio changed the title Upgrading from SvelteKit v260 to v261+ starts returning 500 errors "Dynamic require of "X"" for every page Upgrading from SvelteKit v260 to v261+ starts returning 500 errors "Dynamic require of "X"" for every serverless rendered page Feb 23, 2022
@swyxio
Copy link
Contributor Author

swyxio commented Feb 23, 2022

i have put my failed attempts at debugging into a different branch, so as not to break current users https://github.com/sw-yx/swyxkit/commits/debuggingVersions

@geoffrich
Copy link
Member

Possibly related: #3978 (comment) and #4058. Does removing node_bundler help?

@PH4NTOMiki
Copy link
Contributor

Possibly related: #3978 (comment) and #4058. Does removing node_bundler help?

I just tried with removing node_bundler, still the same

@swyxio
Copy link
Contributor Author

swyxio commented Feb 23, 2022

confirmed that removing node bundler did not help :( any other options?

@PH4NTOMiki
Copy link
Contributor

I'm currently testing this, will let you know how it turns out.

@PH4NTOMiki
Copy link
Contributor

I think it's Netlify handling of node_modules

@PH4NTOMiki
Copy link
Contributor

created issue netlify/zip-it-and-ship-it#1036

@PH4NTOMiki
Copy link
Contributor

Netlify reverted to working version of ZISI

@swyxio
Copy link
Contributor Author

swyxio commented Feb 25, 2022

WOW so it was not my/our fault?!? amazing. thank you so much, will retry.

edit: confirmed that a simple rebuild fixed it, now that Netlify reverted their change. watch netlify/zip-it-and-ship-it#1036 for when they try it again.

@swyxio swyxio closed this as completed Feb 25, 2022
@swyxio swyxio changed the title Upgrading from SvelteKit v260 to v261+ starts returning 500 errors "Dynamic require of "X"" for every serverless rendered page Netlify briefly broke esbuild builds, causing "Dynamic require of "X"" errors for every serverless rendered page [fixed] Feb 25, 2022
@PH4NTOMiki
Copy link
Contributor

@sw-yx no problem man, yeah, I was pretty sure it wasn't your/our problem, and I checked all the recent SvelteKit changes and there wasn't anything breaking, and when I tried to deploy it to Vercel, and it was working no issue, and the dev was working, so I figured the issue has to be something with Netlify, something with their build/packaging process.
Glad it works now.

@PH4NTOMiki
Copy link
Contributor

Esbuild source issue: evanw/esbuild#1921

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

No branches or pull requests

3 participants