Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on suspense in blocking rendering mode #28117

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 5 additions & 9 deletions packages/next/shared/lib/dynamic.tsx
Expand Up @@ -114,15 +114,11 @@ export default function dynamic<P = {}>(
loadableOptions = { ...loadableOptions, ...options }

const suspenseOptions = loadableOptions as LoadableSuspenseOptions<P>
if (!process.env.__NEXT_CONCURRENT_FEATURES) {
// Error if react root is not enabled and `suspense` option is set to true
if (!process.env.__NEXT_REACT_ROOT && suspenseOptions.suspense) {
// TODO: add error doc when this feature is stable
throw new Error(
`Disallowed suspense option usage with next/dynamic in blocking mode`
)
}
suspenseOptions.suspense = false
if (!process.env.__NEXT_CONCURRENT_FEATURES && suspenseOptions.suspense) {
// TODO: add error doc when this feature is stable
throw new Error(
`Disallowed suspense option usage with next/dynamic in blocking mode`
)
}
if (suspenseOptions.suspense) {
return loadableFn(suspenseOptions)
Expand Down
10 changes: 0 additions & 10 deletions test/integration/react-18/app/pages/suspense/unwrapped.js

This file was deleted.

31 changes: 0 additions & 31 deletions test/integration/react-18/test/basics.js

This file was deleted.

27 changes: 0 additions & 27 deletions test/integration/react-18/test/blocking.js

This file was deleted.

28 changes: 4 additions & 24 deletions test/integration/react-18/test/index.test.js
Expand Up @@ -12,9 +12,7 @@ import {
nextStart,
renderViaHTTP,
} from 'next-test-utils'
import blocking from './blocking'
import concurrent from './concurrent'
import basics from './basics'

jest.setTimeout(1000 * 60 * 5)

Expand Down Expand Up @@ -80,14 +78,6 @@ describe('React 18 Support', () => {
expect(output).not.toMatch(USING_CREATE_ROOT)
expect(output).not.toMatch(UNSUPPORTED_PRERELEASE)
})

it('suspense is not allowed in blocking rendering mode', async () => {
const appPort = await findPort()
const app = await launchApp(appDir, appPort)
const html = await renderViaHTTP(appPort, '/suspense/unwrapped')
await killApp(app)
expect(html).toContain(SUSPENSE_ERROR_MESSAGE)
})
})

describe('warns with stable supported version of react-dom', () => {
Expand Down Expand Up @@ -117,13 +107,6 @@ describe('React 18 Support', () => {
})
})

describe('Basics', () => {
runTests('default setting with react 18', 'dev', (context) => basics(context))
runTests('default setting with react 18', 'prod', (context) =>
basics(context)
)
})

describe('Blocking mode', () => {
beforeAll(() => {
dynamicHello.replace('suspense = false', `suspense = true`)
Expand All @@ -132,13 +115,10 @@ describe('Blocking mode', () => {
dynamicHello.restore()
})

runTests('concurrentFeatures is disabled', 'dev', (context) =>
blocking(context, (p, q) => renderViaHTTP(context.appPort, p, q))
)

runTests('concurrentFeatures is disabled', 'prod', (context) =>
blocking(context, (p, q) => renderViaHTTP(context.appPort, p, q))
)
it('suspense is not allowed in blocking rendering mode (prod)', async () => {
const output = await getBuildOutput(appDir)
expect(output).toContain(SUSPENSE_ERROR_MESSAGE)
})
})

describe('Concurrent mode', () => {
Expand Down