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
Using Prisma with Rollup or Webpack in Node causes a runtime error #5250
Comments
Can you share a simple reproduction? Then we can confirm this and maybe replace node-fetch with something else as it is not a very core dependency. We have some e2e tests for bundlers which havent failed so maybe you can look them as an example: https://github.com/prisma/e2e-tests/tree/dev/bundlers |
I’ll create a reproduction. The e2e tests are not failing because this test is basically ignoring everything under node_modules when bundling through webpack-node-externals plugin. I can’t do that for my use case. I need to provide a single archive of my app to lambda including all dependencies so I need to bundle them.
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Harshit Pant <notifications@github.com>
Sent: Wednesday, January 27, 2021 8:10:59 PM
To: prisma/prisma <prisma@noreply.github.com>
Cc: Sid <sid_26@outlook.com>; Author <author@noreply.github.com>
Subject: Re: [prisma/prisma] Using Prisma with Rollup or Webpack in Node causes a runtime error (#5250)
Can you share a simple reproduction? Then we can confirm this and maybe replace node-fetch with something else as it is not a very core dependency.
We have some e2e tests for bundlers which havent failed so maybe you can look them as an example: https://github.com/prisma/e2e-tests/tree/dev/bundlers
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#5250 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACBNKC57RQTRLNPTG7QH4CTS4AQXXANCNFSM4WPTU7IA>.
|
Here is the reproduction |
THanks for that. Marking this as confirmed. We can try eliminating this dep. |
You're try bundling node_modules all together in one output JS file, you get a runtime error trying to run that output JS file. PR for context. Am I understanding this correctly? If so, a couple questions:
|
Use case is generating a single asset that I can distribute to serverless environments. without the need to manage things like lambda layers. Also the generated asset is run through a minifier to reduce size and gain marginal improvement in startup perf. The error is basically that a dependency of prisma has an implicit dependency on a module called Ideally considering the reach and popularity of this project, it will be better to not have such implicit dependencies or make assumptions about the modules available at runtime. I suggest to either add a note in the docs or better yet replace this dependency with a more sensible choice. |
Tbh I don't fully understand why/how the crash happens and it's been a while since I encountered it. I was able to resolve it by making modifications to the bundler config. A guess is that perhaps the bundler hoists the require calls. |
This is the config that worked for me: #2303 (comment) |
Why isn't renovate suggesting an update to |
Because v3 in not on latest but on next. I re-configured Renovate, it should open a PR soon 3c00990 |
Ugh, so the README at https://github.com/node-fetch/node-fetch lies to us :/ |
Indeed... README is incorrect Created an issue node-fetch/node-fetch#1184 |
what can I do to circumvent this issue? |
You can mark this dependency as external for now. |
It seems like the current workaround is to mark the dependency as external. The longer-term fix is to upgrade to node-fetch 3.x, which is currently blocked by #7618. |
Closing this as this is not an issue anymore |
Bug description
I have traced this to
node-fetch
v 2.x which is a dependency of the fetch engine.https://github.com/node-fetch/node-fetch/blob/b5e2e41b2b50bf2997720d6125accaf0dd68c0ab/src/body.js#L14
node-fetch/node-fetch#412
encoding
seems to be a peer dependency fornode-fetch
. A bundler like webpack or rollup will include the require and crash at runtime sinceencoding
is not installed.Either prisma should upgrade the
node-fetch
dependency to v3 which does away with this or include a cautionary note in the README likenode-fetch
did : https://github.com/node-fetch/node-fetch/blob/2.x/README.md#bodytextconvertedOther repos depending on
node-fetch
2.x also faced a similar issue netlify/create-react-app-lambda#24The text was updated successfully, but these errors were encountered: