weaviate / weaviate/typescript-client

`weaviate-client` fails to bundle on Cloudflare Workers due to `http2` dependency

Open
#145 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
101
Forks
38
Avg merge
4d 12h
Merged PRs (30d)
2

Description

Description

I am trying to use the weaviate-client library in a Cloudflare Worker, but I am encountering issues related to the http2 module. The error message suggests that the http2 package is built into Node.js and is not available in the Cloudflare Workers environment.

Context

I have added the following configuration to my wrangler.toml file to enable Node.js compatibility:

compatibility_date = "2023-12-01"
node_compat = true

However, even with this configuration, I am still facing the http2 related error.

Steps to Reproduce

  1. Set up a new Cloudflare Worker project.
  2. Install the weaviate-client library using npm or yarn.
  3. Configure wrangler.toml with the appropriate compatibility_date and node_compat settings.
  4. Write code that uses the weaviate-client library to make requests to a Weaviate instance.
  5. Attempt to run the Worker using wrangler dev.

Expected Behavior

The Cloudflare Worker should be able to use the weaviate-client library to make requests to a Weaviate instance without any issues related to the http2 module.

Actual Behavior

The Worker fails to execute due to the missing http2 module, which is not available in the Cloudflare Workers environment.

✘ [ERROR] Could not resolve "http2"

    ../../node_modules/.pnpm/@grpc+grpc-js@1.9.14/node_modules/@grpc/grpc-js/build/src/transport.js:20:22:
      20 │ const http2 = require("http2");
         ╵                       ~~~~~~~

  The package "http2" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error.

Possible Solution

One potential solution is to use the native fetch API provided by Cloudflare Workers instead of relying on the http2 module used by the weaviate-client library.

Additional Information

  • I'm using Weaviate Cloud
  • weaviate-client library version: 3.0.0-rc.3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with a Cloudflare Worker using weaviate-client 3.0.0-rc.3, the shown wrangler.toml settings, and wrangler dev. Start at @grpc/grpc-js/build/src/transport.js, where http2 is required; done means the Worker bundles and can make requests without the missing-module error.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, node.js, typescript
Domain
api, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.