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: Cannot await or return from a thenable #71991

Closed
rafzan opened this issue Oct 28, 2024 · 2 comments
Closed

Error: Cannot await or return from a thenable #71991

rafzan opened this issue Oct 28, 2024 · 2 comments
Labels
bug Issue was opened via the bug report template. locked

Comments

@rafzan
Copy link

rafzan commented Oct 28, 2024

Link to the code that reproduces this issue

https://github.com/rafzan/thenable-error

To Reproduce

  1. Get to root and try to build the application. You should get Error: Cannot await or return from a thenable

Current vs. Expected behavior

The application should build, like in prior versions.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.0.0: Tue Sep 24 23:37:25 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6030
  Available memory (MB): 18432
  Available CPU cores: 11
Binaries:
  Node: 20.13.1
  npm: 10.5.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 15.0.1 // Latest available version is detected (15.0.1).
  eslint-config-next: 15.0.1
  react: 19.0.0-rc-69d4b800-20241021
  react-dom: 19.0.0-rc-69d4b800-20241021
  typescript: 5.6.3
Next.js Config:
  output: N/A

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

https://nextjs.org/docs/pages/building-your-application/optimizing/lazy-loading

Docs suggest that in order to use dynamic() imports with named exports we should use import('../components/hello').then((mod) => mod.Hello)

By importing a client component from a server component using this pattern for named exports, you get Error: Cannot await or return from a thenable. I'm opening this issue mainly because you get no information whatsoever by searching online yet.

I'd expect either the documentation to explicitly tell that you shouldn't use this pattern on this scenario, or better yet, that docs provided a viable pattern to be used when importing client from server via named exports.

As a quick fix, I just separated every component into its own file and export default each one, thus removing the need for .then

@rafzan rafzan added the bug Issue was opened via the bug report template. label Oct 28, 2024
@unstubbable
Copy link
Contributor

Fixed in 15.0.2-canary.10 via #71968.

Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked
Projects
None yet
Development

No branches or pull requests

2 participants