Git Product home page Git Product logo

Comments (11)

f-elix avatar f-elix commented on April 27, 2024 3

@Kikobeats Everything works now! No error, and logging Event doesn't show undefined anymore. Thanks a lot for your work :)

from edge-runtime.

thillmann avatar thillmann commented on April 27, 2024 2

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.

f-elix avatar f-elix commented on April 27, 2024 1

@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.

Kikobeats avatar Kikobeats commented on April 27, 2024 1

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.

Kikobeats avatar Kikobeats commented on April 27, 2024

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.

f-elix avatar f-elix commented on April 27, 2024

@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.

Kikobeats avatar Kikobeats commented on April 27, 2024

@f-elix are you using Next.js or Vercel CLI?

Also, if you do globalThis.Event what you get? undefined?

from edge-runtime.

f-elix avatar f-elix commented on April 27, 2024

@Kikobeats I'm actually using Sveltekit and deploying with adapter-vercel.

I indeed get undefined if I do globalThis.Event.

from edge-runtime.

Kikobeats avatar Kikobeats commented on April 27, 2024

@f-elix this is now fixed; can you check at your end? 🙂

from edge-runtime.

sundaycrafts avatar sundaycrafts commented on April 27, 2024

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.

f-elix avatar f-elix commented on April 27, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.