next-runtime icon indicating copy to clipboard operation
next-runtime copied to clipboard

fix: prevent Next from defining duplicate global property in edge functions

Open ascorbic opened this issue 3 years ago โ€ข 10 comments

Summary

Currently Next.js creates a global function in the edge runtime called __import_unsupported by defining it as an immutable property on globalThis. This means that if there is more than one of these definitions in a single edge function bundle then there is an error when they both try to define it. This PR patches the generated bundle (yeah, I know) to add a check before defining it. I suppose I could try contributing upstream.

The only scenario where this happens now is if you have more than one Next.js edge function or middleware. This means that you need to define an API route to use experimental-edge runtime, and also have middleware.

Test plan

  1. Visit the middleware deploy preview
  2. Load the edge API page /api/edge

Relevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal

image

Standard checks:

  • [ ] Check the Deploy Preview's Demo site for your PR's functionality
  • [ ] Add docs when necessary

๐Ÿงช Once merged, make sure to update the version if needed and that it was published correctly.

ascorbic avatar Oct 14 '22 16:10 ascorbic

Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-nx-monorepo-demo/deploys/634d0f04f69389000883958e
Deploy Preview https://deploy-preview-1682--netlify-plugin-nextjs-nx-monorepo-demo.netlify.app/
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for netlify-plugin-nextjs-demo ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-demo/deploys/634d0f0305d4e1000996b301
Deploy Preview https://deploy-preview-1682--netlify-plugin-nextjs-demo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for next-plugin-canary ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/next-plugin-canary/deploys/634d0f0404c53000090b6ea3
Deploy Preview https://deploy-preview-1682--next-plugin-canary.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for next-plugin-rsc-demo ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/next-plugin-rsc-demo/deploys/634d0f048c8f1d00087ec033
Deploy Preview https://deploy-preview-1682--next-plugin-rsc-demo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for next-i18next-demo ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/next-i18next-demo/deploys/634d0f04f3bbee000989bd82
Deploy Preview https://deploy-preview-1682--next-i18next-demo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for nextjs-plugin-custom-routes-demo ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/nextjs-plugin-custom-routes-demo/deploys/634d0f04452352000910fb90
Deploy Preview https://deploy-preview-1682--nextjs-plugin-custom-routes-demo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-static-root-demo/deploys/634d0f048c8f1d00087ec029
Deploy Preview https://deploy-preview-1682--netlify-plugin-nextjs-static-root-demo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for next-plugin-edge-middleware ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/next-plugin-edge-middleware/deploys/634d0f04effcc300090824ba
Deploy Preview https://deploy-preview-1682--next-plugin-edge-middleware.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-next-auth-demo/deploys/634d0f042b182500095a17eb
Deploy Preview https://deploy-preview-1682--netlify-plugin-nextjs-next-auth-demo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]

Deploy Preview for netlify-plugin-nextjs-export-demo ready!

Name Link
Latest commit f3465998c565c41156392c36ce32d6c30960b046
Latest deploy log https://app.netlify.com/sites/netlify-plugin-nextjs-export-demo/deploys/634d0f04325d63000806d42b
Deploy Preview https://deploy-preview-1682--netlify-plugin-nextjs-export-demo.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

netlify[bot] avatar Oct 14 '22 16:10 netlify[bot]