rsnext/test/e2e/getserversideprops/app/pages/refresh.js
JJ Kasper 02405e2247
Fix getServerSideProps hanging in dev on early end (#33366)
This fixes the case where calling `res.end()` is `getServerSideProps` would cause the request to hang in development due to our `Proxy` around `res` causing internal `ServerResponse` fields to not be available ([related post](https://javascript.info/proxy#built-in-objects-internal-slots)). I also migrated our `getServerSideProps` test suite to an e2e suite with a test for this case. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/15118
Fixes: https://github.com/vercel/next.js/issues/32824
Closes: https://github.com/vercel/next.js/pull/33129
2022-01-16 16:14:21 +00:00

23 lines
431 B
JavaScript

import { useEffect, useState } from 'react'
const foo = (query) => query
export const FOO = foo('query')
const MyPage = () => {
const [isMounted, setMounted] = useState(false)
useEffect(() => {
setMounted(true)
}, [])
if (isMounted) {
return <p>client loaded</p>
}
return <p>server</p>
}
const getServerSideProps = async () => {
return { props: {} }
}
export default MyPage
export { getServerSideProps }