Skip to content

firebase/firestore breaks Next.js builds due to grpc limitations #2299

Closed
@ctavan

Description

@ctavan

[REQUIRED] Describe your environment

  • Operating System version: macOS 10.14.6 (18G103)
  • Browser version: any
  • Firebase SDK version: 7.1.0
  • Firebase Product: firestore

[REQUIRED] Describe the problem

Using firebase/firestore in Next.js apps currently breaks serverside builds (next build command), see vercel/next.js#7894.

next build uses node worker_thread's to pre-render/optimize SSR pages. If there are multiple pages that import 'firebase/firestore';§ the build fails with:

Error: Failed to load /node_modules/grpc/src/node/extension_binary/node-v72-darwin-x64-unknown/grpc_node.node. Module did not self-register.

The underlying issue seems to be that grpc (native) does not support multiple threads: grpc/grpc-node#778

At first I thought #2010 (comment) was a similar issue and I tried fiddling around with webpack externals config as suggested in #1455 (comment) but to no success.

An obvious "fix" would be to finally migrate to @grpc/grpc-js as suggested in #1783

Any other idea on how to work around this issue?

Steps to reproduce:

See vercel/next.js#7894 (comment)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions