Cloudflare workers and Fauna Dev

Hi, im using Cloudflare Workers with Fauna.

i have issue when use fauna client with local dev.

// not work
const faunaClient = new faunadb.Client({
secret: 'secret',
scheme: 'http',
domain: 'localhost',
port: 8443,
fetch: customFetch

// no issues
const faunaClient = new faunadb.Client({
secret: 'super_secret_key',
fetch: customFetch

No error message to debug.

Any help is welcome.

Is the Fauna Dev Docker image up and running? Can you share the command that you use to start the Docker image?

Is your “not work” example running on Cloudflare? If so, localhost would (likely) refer to that Cloudflare host, not your local machine.

Is your “not work” example running on Cloudflare?

  • No, running local using wrangler dev

Can you share the command that you use to start the Docker image?

  • docker run -d --name faunadb -p 8443:8443 fauna/faunadb

i just want create tests using Fauna Docker Image without use dashboard.fauna to create databases.

my worker is very simple.

addEventListener('fetch', event => {

async function handleRequest(request) {
  const result = await faunaClient.query(Add(2, 2))

  return new Response('Hello worker!', {
    headers: { 'content-type': 'text/plain' },

Can you try running a very simple Node.js script to verify that your Docker image is running correctly?

var faunadb = require('faunadb')
var q = faunadb.query

var client = new faunadb.Client({
  secret: 'secret',
  domain: 'localhost',
  port: 8443,
  scheme: 'http'

client.query(q.Add(1, 1))
.then((res) => console.log(res))
.catch((err) => console.log(err))

If the output is 2, we can be reasonably certain that the Docker image is executing queries.

Yes! This example works fine! No issues with docker faunadb.

But when use with cloudflare workers fail.

its so simple to reproduce this issue, i created this repository to help.

any help are welcome.

I haven’t tried your repo, but wrangler dev does not actually run code on your local machine, it just makes it easier to run Cloudflare Worker code without publishing. Here’s a similar issue filed with Cloudflare:

bad news.

So Cloudflare Workers is not for me, if i cant test fauna localhost.

thanks @LeviWolfe @ewan

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.