I have Mailchimp signup that is implemented using the @mailchimp/mailchimp_marketing api client on a form action. It work perfectly on my dev environment. But when I deploy it on Netlify with the netlify adapter and edge: true, then the form does not work in production. In the edge function logs, this is what I have:
Error: Dynamic require of "node:querystring" is not supported
The import happens in this file:
@mailchimp/mailchimp_marketing/src/ApiClient.js
I don't really know if the problem is with the adapter, the mailchimp client, or netlify edge functions themselves.
Does anybody know what is the best way to investigate this and if there is a fix/workaround I can apply at my end, or if one of the libraries involved needs to be fixed?
Reproduction
As far as I can tell, any project using the netlify adapter with edge: true and having a form action that directly or indirectly tries to import "node:querystring" (@mailchimp/mailchimp_marketing in this case) would throw this error.
Logs
Mar 29, 02:43:56 PM: 01HT577V error Error: Dynamic require of "node:querystring" is not supported
Mar 29, 02:43:56 PM: 01HT577V error at file:///root/.netlify/edge-functions/render.js:13:9
Mar 29, 02:43:56 PM: 01HT577V error at node_modules/@mailchimp/mailchimp_marketing/src/ApiClient.js (file:///root/.netlify/edge-functions/render.js:22428:23)
Mar 29, 02:43:56 PM: 01HT577V error at __require2 (file:///root/.netlify/edge-functions/render.js:19:50)
Mar 29, 02:43:56 PM: 01HT577V error at node_modules/@mailchimp/mailchimp_marketing/src/index.js (file:///root/.netlify/edge-functions/render.js:22780:21)
Mar 29, 02:43:56 PM: 01HT577V error at __require2 (file:///root/.netlify/edge-functions/render.js:19:50)
Mar 29, 02:43:56 PM: 01HT577V error at .svelte-kit/output/server/entries/pages/bid/contact/_page.server.js (file:///root/.netlify/edge-functions/render.js:22801:42)
Mar 29, 02:43:56 PM: 01HT577V error at __init (file:///root/.netlify/edge-functions/render.js:16:56)
Mar 29, 02:43:56 PM: 01HT577V error at .svelte-kit/output/server/nodes/5.js (file:///root/.netlify/edge-functions/render.js:22900:5)
Mar 29, 02:43:56 PM: 01HT577V error at __init (file:///root/.netlify/edge-functions/render.js:16:56)Mar 29, 02:43:56 PM: 01HT577V error at file:///root/.netlify/edge-functions/render.js:27903:52
Describe the bug
I have Mailchimp signup that is implemented using the
@mailchimp/mailchimp_marketing
api client on a form action. It work perfectly on my dev environment. But when I deploy it on Netlify with the netlify adapter andedge: true
, then the form does not work in production. In the edge function logs, this is what I have:The import happens in this file:
I don't really know if the problem is with the adapter, the mailchimp client, or netlify edge functions themselves.
Does anybody know what is the best way to investigate this and if there is a fix/workaround I can apply at my end, or if one of the libraries involved needs to be fixed?
Reproduction
As far as I can tell, any project using the netlify adapter with
edge: true
and having a form action that directly or indirectly tries to import "node:querystring" (@mailchimp/mailchimp_marketing in this case) would throw this error.Logs
System Info
Severity
annoyance
Additional Information
Not sure it makes a difference but the node version at Netlify's end is
18.20.0
.