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

Fast refresh is broken by a lib using inline await #61452

Open
flo-dao opened this issue Jan 31, 2024 · 0 comments
Open

Fast refresh is broken by a lib using inline await #61452

flo-dao opened this issue Jan 31, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Module Resolution Module resolution (CJS / ESM, module resolving).

Comments

@flo-dao
Copy link

flo-dao commented Jan 31, 2024

Link to the code that reproduces this issue

/~https://github.com/flo-dao/repro-fast-refresh

To Reproduce

  1. Start the app in dev
  2. Make a change in index.tsx
  3. You get a full page reload, with a message in the console indicating that fast refresh didn't work

Current vs. Expected behavior

Fast refresh should work

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:51 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6030
Binaries:
  Node: 18.18.2
  npm: 9.8.1
  Yarn: 1.22.21
  pnpm: 8.14.0
Relevant Packages:
  next: 14.1.0
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

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

Not sure, Module resolution (CJS / ESM, module resolving)

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

next dev (local)

Additional context

I pinpointed the code causing the issue in the bson lib, here is the link.

The final code looks like this in bson.mjs:

const nodejsRandomBytes = await (async () => {
    try {
        return (await import('crypto')).randomBytes;
    }
    catch {
        return nodejsMathRandomBytes;
    }
})();

If I turn this into a promise without async await, the fast refresh works as expected.

@flo-dao flo-dao added the bug Issue was opened via the bug report template. label Jan 31, 2024
@github-actions github-actions bot added the Module Resolution Module resolution (CJS / ESM, module resolving). label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Module Resolution Module resolution (CJS / ESM, module resolving).
Projects
None yet
Development

No branches or pull requests

1 participant