Skip to content

Bug: Suspense | client component should have a queue #25964

@xiel

Description

@xiel

React version: 18.2.0
Next version: 13.1.1

Steps To Reproduce

  1. Suspend using a (fake) promise in a client component in app dir (next)
  2. Try to useState after the use() call
'use client';

import { use, useState } from 'react';

const testPromise = new Promise((resolve) => {
  setTimeout(() => {
    resolve('use test promise');
  });
});

export default function Page() {
  use(testPromise);
  useState(0);

  return <h1>Test</h1>;
}

Link to code example:
https://codesandbox.io/s/github/xiel/app-playground/tree/suspense-error/?from-embed=&file=/app/page.tsx

The current behavior

Suspending for a promise in a client component and using state/reducer after results in errors during hydration:

react-dom.development.js?9d87:94 Warning: An error occurred during hydration. The server HTML was replaced with client 

react-dom.development.js?9d87:94 Warning: You are accessing "digest" from the errorInfo object passed to onRecoverableError. 

on-recoverable-error.js?eb92:17 Uncaught Error: Should have a queue. This is likely a bug in React. Please file an issue.

The expected behavior

No error during hydration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions