edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

Invalid value (`uuid`) does not always throw `InvalidValueError`

Open gomain opened this issue 2 years ago • 1 comments

Describe the bug

Passing an invalid UUID string does not always throw InvalidValueError

Reproduction Include the code that is causing the error:

import { createClient } from "edgedb";
import e from "./generated/edgeql-js/index.mjs";

const db = createClient();

type UUID = string;

async function getUser(id: UUID): Promise<{ id: UUID }> {
  const user = await e
    .select(e.User, () => ({
      filter_single: { id },
    }))
    .run(db);
  if (!user) {
    throw new Error(`User with id "${id}" does not exist`);
  }
  return user;
};

try {
  await getUser("invalid-uuid-string");
} catch (error) {
  console.err(error);
}

Schema

module default {

  type User {
  };

};

Expected behavior

Throws an InvalidValueError every time.

Actual Behavior

Sometimes throws [Error: User with id "invalid-uuid-string" does not exist]. After running 2 times, all subsequent runs no longer throw the InvalidValueError. After a long wait (~10 minutes), running throws again, for 2 times. Then continues to not throw. Like there is some caching and/or short circuit going on.

Versions (please complete the following information):

  • OS: linux-nixos (local binany)
  • EdgeDB version: 2.9+b1d697b
  • EdgeDB CLI version: 2.2.6+b869667
  • edgedb-js version: 1.0.2
  • @edgedb/generate version: 0.0.7
  • Typescript version: 4.9.5
  • Node version: v16.18.1

Additional context Running via jest ("27.5.1") with jest-light-runner. Clearing jest's cache does not make any affect.

gomain avatar Feb 09 '23 11:02 gomain

@gomain

If you have a chance, can you bump to the latest stable versions of edgedb, edgedb-js, etc, and report if you're still seeing this behavior? I still suspect a caching issue outside of EdgeDB, but want to start from at least the current stable releases and see if we can replicate this behavior.

scotttrinh avatar May 03 '23 16:05 scotttrinh