Repository: next.js
Issue: Serverside rendered Error page running _app getInitialProps in the client 
Labels: bug,Pages Router

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64
    Binaries:
      Node: 16.15.0
      npm: 8.5.5
      Yarn: N/A
      pnpm: N/A
    Relevant Packages:
      next: 13.4.13-canary.0
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
      typescript: N/A
    Next.js Config:
      output: N/A
```


### Which area(s) of Next.js are affected? (leave empty if unsure)

Data fetching (gS(S)P, getInitialProps)

### Link to the code that reproduces this issue or a replay of the bug

https://github.com/mpltr/next-error-page-server-state-bug-report

### To Reproduce

- Build and start the application
- Application must be ran in production mode

- Navigate to / using a full server side render
- Observe that the title prop with a value of  "SERVER APP TITLE" is displayed and retained from _app.getInitialProps ran on the server

- Navigate to /secondary using a full server side render
- Observe that the title prop with a value of  "SERVER APP TITLE" is displayed and retained from _app.getInitialProps ran on the server
- /secondary is just for example and uses getInitialProps to replicate the error page, seeing as an error page can only use getInitialProps

- Navigate to /tertiary using a full server side render
- Observe that the title prop is initially displayed from the SSR, but is lost during the rendering of the error page
- Observe that "RUNNING APP GIP" is logged to the console in the browser, confirming that _app.getInitialProps is running clientside

### Describe the Bug

_app.getInitialProps is re-ran in the client when serverside rendering a page that errors. This differs from the logic of a working page using its own getInitialProps.

This bug is relevant when:

- getInitialProps is being used in _app to get global props 
    - which contains logic that cannot be ran in the client e.g. fetching data from a CORS protected endpoint 
        - meaning that when it is called clientside, it would return different props than when it was ran serverside

- a serverside rendered page with a getServerSideProps or getStaticProps throws an error causing the error page to render

Suspected issue:

- [this bug fix](https://github.com/vercel/next.js/commit/69f8024aa1cdef3125113c0e6e3cb4ec7c44fe8a) will cause _app.getInitialProps to run again in the client when a server side rendered error page is passed to the client
    - this is because `err` does not exist on `renderErrorProps.props`
    
- having debugged the next package to identify the values of `renderErrorProps` and `renderErrorProps.props`, `err` never appears to be a property on the latter, only on the former, so the error page will **always** cause _app.getInitialProps to be called on the client, rather than using the server props
- I suspect that the check should actually be for `renderErrorProps.err`


Context

- This only applies to serverside rendering. When navigating from the home page to the /tertiary page via clientside navigation, the running of _app.getInitialProps cannot be avoided. This is unrelated to the issue above. 

- The example repo is a basic example to understand the issue in nextjs. The reason this bug is hindering us is when implementing redux using next-redux-wrapper, an error page SSR causes the entire store to be reset when clientside rendering. An example of this is in the same repo under the branch [with-redux](https://github.com/mpltr/next-error-page-server-state-bug-report/tree/with-redux). Note in this branch that serverside rendering any page results in the state being maintained throughout the life of the application (when clientside navigating from then on). Only when serverside rendering the /tertiary page do we lose the server state in the client.

### Expected Behavior

The error page should not re-run the _app.getInitialProps in the client when it has been serverside rendered and should instead retain its server props.

### Which browser are you using? (if relevant)

_No response_

### How are you deploying your application? (if relevant)

_No response_