netlify / next-runtime

The Next.js Runtime allows Next.js to run on Netlify with zero configuration
https://www.npmjs.com/package/@netlify/plugin-nextjs
655 stars 86 forks source link

[Bug]: Edge Functions Beta - Middleware rewrites not working as expected #1321

Closed JohnGemstone closed 2 years ago

JohnGemstone commented 2 years ago

Summary

I've updated my middleware AB testing repo to test out the Edge Functions Beta in 4.4.2 and came across these following bugs. Comparisons are with the same repo but with the Edge Functions environment variable set to true or false respectively.


Edge functions ON

standard routes:

  • accessing page via next/link doesn't rewrite

dynamic routes:

  • accessing page via next/link doesn't rewrite
  • accessing page directly 'flashes' rewrite page content then reverts to original

Edge functions OFF (deployed here)

standard & dynamic routes

  • working as expected

Steps to reproduce

Go to my repo and choose either standard or dynamic routes.

dynamic routes:

standard routes:

A link to a reproduction repository

https://github.com/JohnGemstone/abtest-netlify-next

Plugin version

4.4.2

More information about your build

What OS are you using?

Mac OS

Your netlify.toml file

`netlify.toml` ```toml [[plugins]] package = "@netlify/plugin-nextjs" ```

Builds logs (or link to your logs)

Build logs ``` 4:07:27 PM: Build ready to start 4:07:28 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal) 4:07:28 PM: build-image tag: v4.8.0 4:07:28 PM: buildbot version: e58b6be665675c0f99b33132a8c1eec1f775eba1 4:07:29 PM: Fetching cached dependencies 4:07:29 PM: Starting to download cache of 169.1MB 4:07:32 PM: Finished downloading cache in 2.777387504s 4:07:32 PM: Starting to extract cache 4:07:36 PM: Finished extracting cache in 4.832548551s 4:07:36 PM: Finished fetching cache in 7.634145433s 4:07:36 PM: Starting to prepare the repo for build 4:07:37 PM: Preparing Git Reference refs/heads/main 4:07:37 PM: Parsing package.json dependencies 4:07:38 PM: Starting build script 4:07:38 PM: Installing dependencies 4:07:38 PM: Python version set to 2.7 4:07:38 PM: Started restoring cached node version 4:07:40 PM: Finished restoring cached node version 4:07:40 PM: v16.14.2 is already installed. 4:07:41 PM: Now using node v16.14.2 (npm v8.5.0) 4:07:41 PM: Started restoring cached build plugins 4:07:41 PM: Finished restoring cached build plugins 4:07:41 PM: Attempting ruby version 2.7.2, read from environment 4:07:42 PM: Using ruby version 2.7.2 4:07:42 PM: Using PHP version 8.0 4:07:43 PM: No npm workspaces detected 4:07:43 PM: Started restoring cached node modules 4:07:43 PM: Finished restoring cached node modules 4:07:43 PM: Started restoring cached go cache 4:07:43 PM: Finished restoring cached go cache 4:07:43 PM: go version go1.16.5 linux/amd64 4:07:43 PM: go version go1.16.5 linux/amd64 4:07:43 PM: Installing missing commands 4:07:43 PM: Verify run directory 4:07:45 PM: ​ 4:07:45 PM: ──────────────────────────────────────────────────────────────── 4:07:45 PM: Netlify Build 4:07:45 PM: ──────────────────────────────────────────────────────────────── 4:07:45 PM: ​ 4:07:45 PM: ❯ Version 4:07:45 PM: @netlify/build 27.0.1 4:07:45 PM: ​ 4:07:45 PM: ❯ Flags 4:07:45 PM: baseRelDir: true 4:07:45 PM: buildId: 626021aff06fb3372dd1a028 4:07:45 PM: deployId: 626021aff06fb3372dd1a02a 4:07:45 PM: ​ 4:07:45 PM: ❯ Current directory 4:07:45 PM: /opt/build/repo 4:07:45 PM: ​ 4:07:45 PM: ❯ Config file 4:07:45 PM: /opt/build/repo/netlify.toml 4:07:45 PM: ​ 4:07:45 PM: ❯ Context 4:07:45 PM: production 4:07:45 PM: ​ 4:07:45 PM: ❯ Loading plugins 4:07:45 PM: - @netlify/plugin-nextjs@4.4.2 from netlify.toml and package.json 4:07:47 PM: ​ 4:07:47 PM: ──────────────────────────────────────────────────────────────── 4:07:47 PM: 1. @netlify/plugin-nextjs (onPreBuild event) 4:07:47 PM: ──────────────────────────────────────────────────────────────── 4:07:47 PM: ​ 4:07:47 PM: Next.js cache restored. 4:07:47 PM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed. 4:07:47 PM: ​ 4:07:47 PM: (@netlify/plugin-nextjs onPreBuild completed in 106ms) 4:07:47 PM: ​ 4:07:47 PM: ──────────────────────────────────────────────────────────────── 4:07:47 PM: 2. Build command from Netlify app 4:07:47 PM: ──────────────────────────────────────────────────────────────── 4:07:47 PM: ​ 4:07:47 PM: $ npm run build 4:07:47 PM: > abtest-netlify-next@0.1.0 build 4:07:47 PM: > next build 4:07:48 PM: info - Checking validity of types... 4:07:48 PM: warn - No ESLint configuration detected. Run next lint to begin setup 4:07:48 PM: info - Creating an optimized production build... 4:07:49 PM: warn - using beta Middleware (not covered by semver) - https://nextjs.org/docs/messages/beta-middleware 4:07:51 PM: info - Compiled successfully 4:07:51 PM: info - Collecting page data... 4:07:52 PM: info - Generating static pages (0/20) 4:07:53 PM: info - Generating static pages (5/20) 4:07:53 PM: info - Generating static pages (10/20) 4:07:53 PM: info - Generating static pages (15/20) 4:07:53 PM: info - Generating static pages (20/20) 4:07:53 PM: info - Finalizing page optimization... 4:07:53 PM: Page Size First Load JS 4:07:53 PM: ┌ ○ / 2.83 kB 78.6 kB 4:07:53 PM: ├ /_app 0 B 75.7 kB 4:07:53 PM: ├ ○ /404 2.5 kB 78.2 kB 4:07:53 PM: ├ λ /api/hello 0 B 75.7 kB 4:07:53 PM: ├ ○ /dynamic-routes 2.8 kB 78.5 kB 4:07:53 PM: ├ ○ /dynamic-routes-no-middleware 2.81 kB 78.5 kB 4:07:53 PM: ├ ● /dynamic-routes-no-middleware/[slug] 3.06 kB 78.8 kB 4:07:53 PM: ├ ├ /dynamic-routes-no-middleware/product-0 4:07:53 PM: ├ ├ /dynamic-routes-no-middleware/product-1 4:07:53 PM: ├ └ /dynamic-routes-no-middleware/product-2 4:07:53 PM: ├ ƒ /dynamic-routes/_middleware 1.49 kB 103 kB 4:07:53 PM: ├ ● /dynamic-routes/[slug] 3.06 kB 78.8 kB 4:07:53 PM: ├ ├ /dynamic-routes/product-0 4:07:53 PM: ├ ├ /dynamic-routes/product-1 4:07:53 PM: ├ └ /dynamic-routes/product-2 4:07:53 PM: ├ ● /dynamic-routes/test/[slug] 3.06 kB 78.8 kB 4:07:53 PM: ├ ├ /dynamic-routes/test/product-0 4:07:53 PM: ├ ├ /dynamic-routes/test/product-1 4:07:53 PM: ├ └ /dynamic-routes/test/product-2 4:07:53 PM: ├ ○ /redirects/foo 2.58 kB 78.3 kB 4:07:53 PM: ├ ○ /standard-routes 2.79 kB 78.5 kB 4:07:53 PM: ├ ƒ /standard-routes/_middleware 1.49 kB 103 kB 4:07:53 PM: ├ ○ /standard-routes/product-a 2.98 kB 78.7 kB 4:07:53 PM: ├ ○ /standard-routes/product-b 3.01 kB 78.7 kB 4:07:53 PM: ├ ○ /standard-routes/product-c 2.99 kB 78.7 kB 4:07:53 PM: └ ○ /standard-routes/test/product-b 3.02 kB 78.7 kB 4:07:53 PM: + First Load JS shared by all 75.7 kB 4:07:53 PM: ├ chunks/framework-e70c6273bfe3f237.js 42 kB 4:07:53 PM: ├ chunks/main-140541cfe64730a4.js 32.4 kB 4:07:53 PM: ├ chunks/pages/_app-f55443f2448c8e66.js 493 B 4:07:53 PM: ├ chunks/webpack-69bfa6990bb9e155.js 769 B 4:07:53 PM: └ css/abf7a34bb63aaecc.css 1.97 kB 4:07:53 PM: ƒ (Middleware) intercepts requests (uses _middleware) 4:07:53 PM: λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps) 4:07:53 PM: ○ (Static) automatically rendered as static HTML (uses no initial props) 4:07:53 PM: ● (SSG) automatically generated as static HTML + JSON (uses getStaticProps) 4:07:53 PM: ​ 4:07:53 PM: (build.command completed in 5.8s) 4:07:53 PM: ​ 4:07:53 PM: ──────────────────────────────────────────────────────────────── 4:07:53 PM: 3. @netlify/plugin-nextjs (onBuild event) 4:07:53 PM: ──────────────────────────────────────────────────────────────── 4:07:53 PM: ​ 4:07:53 PM: Patching /opt/build/repo/node_modules/next/dist/server/base-server.js 4:07:53 PM: Done 4:07:53 PM: Patching /opt/build/repo/node_modules/next/dist/server/next-server.js 4:07:53 PM: Done 4:07:53 PM: Moving static page files to serve from CDN... 4:07:53 PM: Moved 27 files 4:07:53 PM: ✨ Deploying to Netlify Edge Functions ✨ 4:07:53 PM: This feature is in beta. Please share your feedback here: https://ntl.fyi/next-netlify-edge 4:07:53 PM: Netlify configuration property "redirects" value changed to [ 4:07:53 PM: { from: '/_next/static/*', to: '/static/:splat', status: 200 }, 4:07:53 PM: { from: '/_ipx/*', to: '/.netlify/builders/_ipx', status: 200 }, 4:07:53 PM: { from: '/cache/*', to: '/404.html', status: 404, force: true }, 4:07:53 PM: { from: '/server/*', to: '/404.html', status: 404, force: true }, 4:07:53 PM: { from: '/serverless/*', to: '/404.html', status: 404, force: true }, 4:07:53 PM: { from: '/trace', to: '/404.html', status: 404, force: true }, 4:07:53 PM: { from: '/traces', to: '/404.html', status: 404, force: true }, 4:07:53 PM: { 4:07:53 PM: from: '/routes-manifest.json', 4:07:53 PM: to: '/404.html', 4:07:53 PM: status: 404, 4:07:53 PM: force: true 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/build-manifest.json', 4:07:53 PM: to: '/404.html', 4:07:53 PM: status: 404, 4:07:53 PM: force: true 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/prerender-manifest.json', 4:07:53 PM: to: '/404.html', 4:07:53 PM: status: 404, 4:07:53 PM: force: true 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/react-loadable-manifest.json', 4:07:53 PM: to: '/404.html', 4:07:53 PM: status: 404, 4:07:53 PM: force: true 4:07:53 PM: }, 4:07:53 PM: { from: '/BUILD_ID', to: '/404.html', status: 404, force: true }, 4:07:53 PM: { 4:07:53 PM: from: '/api', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/api/*', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/favicon.ico', 4:07:53 PM: to: '/favicon.ico', 4:07:53 PM: conditions: { Cookie: [Array] }, 4:07:53 PM: status: 200 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/vercel.svg', 4:07:53 PM: to: '/vercel.svg', 4:07:53 PM: conditions: { Cookie: [Array] }, 4:07:53 PM: status: 200 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/*', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: conditions: { Cookie: [Array] }, 4:07:53 PM: force: true 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/index.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/404.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/404', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/dynamic-routes.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/dynamic-routes', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/dynamic-routes-no-middleware.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/dynamic-routes-no-middleware', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/redirects/foo.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/redirects/foo', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/standard-routes.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/standard-routes', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/standard-routes/product-a.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/standard-routes/product-a', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/standard-routes/product-b.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/standard-routes/product-b', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/standard-routes/product-c.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/standard-routes/product-c', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/standard-routes/test/product-b.json', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/standard-routes/test/product-b', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/dynamic-routes/test/:slug.json', 4:07:53 PM: to: '/.netlify/builders/___netlify-odb-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/dynamic-routes/test/:slug', 4:07:53 PM: to: '/.netlify/builders/___netlify-odb-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/dynamic-routes/:slug.json', 4:07:53 PM: to: '/.netlify/builders/___netlify-odb-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/dynamic-routes/:slug', 4:07:53 PM: to: '/.netlify/builders/___netlify-odb-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/_next/data/RVWVcRwrmtRpiKrG5BGpP/dynamic-routes-no-middleware/:slug.json', 4:07:53 PM: to: '/.netlify/builders/___netlify-odb-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/dynamic-routes-no-middleware/:slug', 4:07:53 PM: to: '/.netlify/builders/___netlify-odb-handler', 4:07:53 PM: status: 200, 4:07:53 PM: force: false 4:07:53 PM: }, 4:07:53 PM: { 4:07:53 PM: from: '/*', 4:07:53 PM: to: '/.netlify/functions/___netlify-handler', 4:07:53 PM: status: 200 4:07:53 PM: } 4:07:53 PM: ]. 4:07:53 PM: ​ 4:07:53 PM: (@netlify/plugin-nextjs onBuild completed in 145ms) 4:07:53 PM: ​ 4:07:53 PM: ──────────────────────────────────────────────────────────────── 4:07:53 PM: 4. Functions bundling 4:07:53 PM: ──────────────────────────────────────────────────────────────── 4:07:53 PM: ​ 4:07:53 PM: Packaging Functions from .netlify/functions-internal directory: 4:07:53 PM: - ___netlify-handler/___netlify-handler.js 4:07:53 PM: - ___netlify-odb-handler/___netlify-odb-handler.js 4:07:53 PM: - _ipx/_ipx.js 4:07:53 PM: ​ 4:08:07 PM: ​ 4:08:07 PM: (Functions bundling completed in 14.2s) 4:08:07 PM: ​ 4:08:07 PM: ──────────────────────────────────────────────────────────────── 4:08:07 PM: 5. Edge Functions bundling 4:08:07 PM: ──────────────────────────────────────────────────────────────── 4:08:07 PM: ​ 4:08:07 PM: Packaging Edge Functions from .netlify/edge-functions directory: 4:08:07 PM: - ipx 4:08:07 PM: - next_dynamic_routes 4:08:07 PM: - next_standard_routes 4:08:07 PM: Warning Implicitly using latest version (2.1.1) for https://deno.land/x/accepts/mod.ts 4:08:12 PM: ​ 4:08:12 PM: (Edge Functions bundling completed in 4.9s) 4:08:12 PM: ​ 4:08:12 PM: ──────────────────────────────────────────────────────────────── 4:08:12 PM: 6. @netlify/plugin-nextjs (onPostBuild event) 4:08:12 PM: ──────────────────────────────────────────────────────────────── 4:08:12 PM: ​ 4:08:12 PM: Next.js cache saved. 4:08:12 PM: ​ 4:08:12 PM: (@netlify/plugin-nextjs onPostBuild completed in 92ms) 4:08:12 PM: ​ 4:08:13 PM: Creating deploy upload records 4:08:12 PM: ──────────────────────────────────────────────────────────────── 4:08:12 PM: 7. Deploy site 4:08:12 PM: ──────────────────────────────────────────────────────────────── 4:08:12 PM: ​ 4:08:12 PM: Starting to deploy site from '.next' 4:08:12 PM: Creating deploy tree 4:08:13 PM: 38 new files to upload 4:08:13 PM: 2 new functions to upload 4:08:26 PM: Site deploy was successfully initiated 4:08:26 PM: ​ 4:08:26 PM: (Deploy site completed in 13.4s) 4:08:26 PM: ​ 4:08:26 PM: ──────────────────────────────────────────────────────────────── 4:08:26 PM: Netlify Build Complete 4:08:26 PM: ──────────────────────────────────────────────────────────────── 4:08:26 PM: ​ 4:08:26 PM: (Netlify Build completed in 40.7s) 4:08:26 PM: Starting post processing 4:08:26 PM: Caching artifacts 4:08:26 PM: Started saving node modules 4:08:26 PM: Finished saving node modules 4:08:26 PM: Started saving build plugins 4:08:26 PM: Finished saving build plugins 4:08:26 PM: Started saving pip cache 4:08:26 PM: Finished saving pip cache 4:08:26 PM: Started saving emacs cask dependencies 4:08:26 PM: Post processing - HTML 4:08:26 PM: Finished saving emacs cask dependencies 4:08:26 PM: Started saving maven dependencies 4:08:26 PM: Finished saving maven dependencies 4:08:26 PM: Started saving boot dependencies 4:08:26 PM: Finished saving boot dependencies 4:08:26 PM: Started saving rust rustup cache 4:08:26 PM: Finished saving rust rustup cache 4:08:26 PM: Started saving go dependencies 4:08:26 PM: Finished saving go dependencies 4:08:26 PM: Build script success 4:08:30 PM: Post processing - header rules 4:08:30 PM: Post processing - redirect rules 4:08:31 PM: Post processing done 4:08:34 PM: Site is live ✨ 4:08:55 PM: Finished processing build request in 1m26.121008924s ```
JohnGemstone commented 2 years ago

Thanks for the quick fix for this! Unfortunately I've found another possible bug related to this. Whenever I go to the dynamic AB test route the edge function goes into an endless loop (4 times a second) with the following logs:

1:18:16 AM: middleware NextResponse {
  body: null,
  bodyUsed: false,
  headers: Headers {
  "x-middleware-rewrite": "https://abtest-middleware.netlify.app/dynamic-routes/test/product-1"
},
  ok: true,
  redirected: false,
  status: 200,
  statusText: "",
  url: ""
}
1:18:16 AM: middleware NextResponse {
  body: null,
  bodyUsed: false,
  headers: Headers {
  "x-middleware-rewrite": "https://abtest-middleware.netlify.app/dynamic-routes/test/product-1"
},
  ok: true,
  redirected: false,
  status: 200,
  statusText: "",
  url: ""
}
[...]

NOTE: I reverted my deploy to protect my quota but anyone should be able to reproduce the bug from my git repo.

I'd like to try and drop next middleware for pure edge functions as recommended, but it will require some time testing to see how it behaves with prefetching via next/Link.

Thanks again!

ericapisani commented 2 years ago

Hi @JohnGemstone ,

Thanks for the follow up bug report (and an even bigger thank you for the initial reproduction project, was extremely helpful)!

@ascorbic has just merged a fix for the infinite reload loop that you mentioned as part of #1325 . Hopefully that sorts things out, but if there's any other bugs that come out of the woodwork, don't hesitate to reach out again.

JohnGemstone commented 2 years ago

No problem, thanks for getting the fixes across so quickly! Excited to try out 4.5.0 🛡️