Comments (11)
@Kikobeats Everything works now! No error, and logging Event
doesn't show undefined
anymore. Thanks a lot for your work :)
from edge-runtime.
I was able to get Stripe to work on Vercel's edge function by using a polyfill (event-target-polyfill
) for the events api. This seems to work (at least for the way I'm using Stripe).
from edge-runtime.
@thillmann Thank you so much! All my edge functions using stripe-node now work :)
Still it would be nice if this could be added to Vercel's edge runtime.
from edge-runtime.
Hello,
The original issue reported support for Event
, but I didn't note EventTarget
should be added as well.
Now, both are working properly at production.
source code:
export const config = { runtime: 'edge' }
export default () => {
return Response.json({
queueMicrotask: !!queueMicrotask,
Event: !!Event,
EventTarget: !!EventTarget
})
}
deployment: https://edge-api-one.vercel.app/api
I tested manually in a project running npm i stripe
on the Edge, and it works flawless.
Can you confirm at your end? 🙂
from edge-runtime.
The Edge Runtime core is using event-target-shim which provides Event
and EventTarget
polyfills.
Maybe this was an issue in the past, but it seems like it's working as expected:
❯ edge-runtime --repl
ƒ => !!Event
true
ƒ => !!EventTarget
true
ƒ =>
I'm going to close for now, but please feel free to comment if I'm missing something 🙏
from edge-runtime.
@Kikobeats, I tried again without event-target-polyfill
and I am still getting the same error.
The error is TypeError: Class extends value undefined is not a constructor or null
because of an internal stripe-node
class that extends Event
, so it seems that Event
is still undefined at runtime without the polyfill. Hope that helps!
from edge-runtime.
@f-elix are you using Next.js or Vercel CLI?
Also, if you do globalThis.Event
what you get? undefined?
from edge-runtime.
@Kikobeats I'm actually using Sveltekit and deploying with adapter-vercel.
I indeed get undefined
if I do globalThis.Event
.
from edge-runtime.
@f-elix this is now fixed; can you check at your end? 🙂
from edge-runtime.
I think this issue is still going on. Here is a error message from stripe-node
TypeError: EventTarget is not a constructor
at (node_modules/stripe/esm/StripeEmitter.js:15:27)
at (node_modules/stripe/esm/platform/WebPlatformFunctions.js:13:15)
at (node_modules/stripe/esm/stripe.core.js:48:43)
at (app/api/order_hook/route.ts:7:15)
at (webpack/bootstrap:21:0)
at (node_modules/luxon/src/datetime.js:2248:0)
at (webpack/runtime/jsonp chunk loading:34:0)
at (api/my_hook:middleware.js:1:17)
from edge-runtime.
@Kikobeats Sorry for the delay! I'm still getting the same error:
TypeError: Class extends value undefined is not a constructor or null
at (../../../../node_modules/stripe/esm/StripeEmitter.js:6:6)
at (../../../../.svelte-kit/vercel-tmp/fn/edge.js:13:7)
at (../../../../node_modules/stripe/esm/platform/WebPlatformFunctions.js:2:0)
at (../../../../.svelte-kit/vercel-tmp/fn/edge.js:13:7)
at (../../../../node_modules/stripe/esm/stripe.esm.worker.js:1:0)
at (../../../../.svelte-kit/vercel-tmp/fn/edge.js:13:7)
at (../../../../.svelte-kit/output/server/chunks/stripe.js:1:0)
at (../../../../.svelte-kit/vercel-tmp/fn/edge.js:13:7)
at (../../../../.svelte-kit/output/server/entries/pages/_locale_lang_/_slug_slug_signup_/_page.server.ts.js:9:0)
at (../../../../.svelte-kit/vercel-tmp/fn/edge.js:13:7)
from edge-runtime.
Related Issues (20)
- Include a key in process.versions for detecting edge runtime HOT 2
- Support `has` in ResponseCookies
- Set-Cookie headers are merged when using `fetch` HOT 6
- Primitives: event-target-shim causes issues w/ edge-runtime running on top of node HOT 3
- drop node16 support
- Proxying primitive instances return anonymous `toString()` return functions
- Why cannot my `fetch` API work in edge function? HOT 4
- 🙏`fetch` api doesn't work in edge function HOT 4
- Which functions and APIs advance the value returned by `Date.now`? HOT 3
- Polyfill for btoa inconsistent with WebApi / Node HOT 5
- drop node18 support
- Response.redirect() fails to parse some URLs in production which parse successfully in local runtime HOT 2
- `@edge-runtime/node-utils` can't start example server from docs using `primitives` (node v18.18.2) Headers2 is not a constructor HOT 1
- Secure Cookies can't be deleted from Responses
- CompressionStream / DecompressionStream support?
- failing on buffer
- Does Edge Runtime use alternative vm instead of node:vm? HOT 3
- crypto.subtle.importKey does not accept ArrayBuffer (ArrayBuffer.prototype mismatch) HOT 1
- Cannot use @edge-runtime/jest-environment
- Support for CloudFlare Connect () TCP Workers API
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from edge-runtime.