Git Product home page Git Product logo

Comments (3)

icyJoseph avatar icyJoseph commented on September 23, 2024 1

This has been reported here as well:

Since the _rsc request is discarded, in light of a redirect, the tests setup in test/e2e/app-dir/navigation/navigation.test.ts pass, but the issue is there too.

For example, say, you have this route handler:

// test/e2e/app-dir/navigation/app/redirect/result/api/route.js
let t = 0
const getTime = () => t++

export const GET = (req) => {
  const rsc = req.nextUrl.searchParams.get('_rsc')
  return new Response(
    `<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>

    <body>
        <h1 id="result-page">Result Page</h1>
        <div id="counter">${getTime()}</div>
        <div id="rsc">${rsc || 'no-rsc'}</div>
    </body>
</html>
  `,
    { status: 200, statusText: 'OK', headers: { 'Content-Type': 'text/html' } }
  )
}

Then you can write a test:

// test/e2e/app-dir/navigation/navigation.test.ts around line 500-ish
   it('should only trigger the redirect once for Route Handlers', async () => {
        const path = '/redirect/redirect-with-loading/to-api'
        const browser = await next.browser(path)

        const counter = await browser.waitForElementByCss('#counter').text()

        expect(counter).toBe('0')
      })

And that'll error out because counter will be actually 1.

I haven't had time to deep dive into why the _rsc request is made though

from next.js.

cfrank avatar cfrank commented on September 23, 2024

Fixed #66620

from next.js.

github-actions avatar github-actions commented on September 23, 2024

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

from next.js.

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.