File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed
packages/next/next-server/server
test/integration/concurrent-document-component-error/test Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -460,7 +460,10 @@ export async function renderToHTML(
460460 ! isSSG &&
461461 ! getServerSideProps
462462
463- if ( process . env . NEXT_CONCURRENT_FEATURES && typeof Document !== 'function' ) {
463+ if (
464+ ( process . env . NEXT_CONCURRENT_FEATURES && typeof Document !== 'function' ) ||
465+ Document . prototype
466+ ) {
464467 throw new Error ( CUSTOM_DOCUMENT_RSC_ERROR + ` ${ pathname } ` )
465468 }
466469
Original file line number Diff line number Diff line change 11/* eslint-env jest */
22
33import { join } from 'path'
4- import { nextBuild } from 'next-test-utils'
4+ import {
5+ renderViaHTTP ,
6+ findPort ,
7+ launchApp ,
8+ killApp ,
9+ nextBuild ,
10+ } from 'next-test-utils'
511import { CUSTOM_DOCUMENT_RSC_ERROR } from 'next/dist/lib/constants'
612
713jest . setTimeout ( 1000 * 60 )
@@ -12,4 +18,25 @@ describe('Concurrent Document Component Errors', () => {
1218 const { stderr } = await nextBuild ( appDir , [ ] , { stderr : true } )
1319 expect ( stderr ) . toContain ( CUSTOM_DOCUMENT_RSC_ERROR )
1420 } )
21+
22+ describe ( 'development mode' , ( ) => {
23+ let output
24+
25+ beforeAll ( async ( ) => {
26+ const handleOutput = ( msg ) => {
27+ output += msg
28+ }
29+ const appPort = await findPort ( )
30+ const app = await launchApp ( appDir , appPort , {
31+ onStdout : handleOutput ,
32+ onStderr : handleOutput ,
33+ } )
34+ await renderViaHTTP ( appPort , '/' )
35+ await killApp ( app )
36+ } )
37+
38+ it ( 'errors when document is a class component' , ( ) => {
39+ expect ( output ) . toContain ( CUSTOM_DOCUMENT_RSC_ERROR )
40+ } )
41+ } )
1542} )
You can’t perform that action at this time.
0 commit comments