Solution found for client.fetch() hanging in Remix 1.12 with Express and Node 16.17.1

3 replies
Last updated: Jun 5, 2023
Hello, I am having a really hard time figuring out why my client.fetch(“count(*)“) hangs. I’m using remix 1.12 with express, node 16.17.1. And sanity client 6.1.2. Here is the code I use directly on the loader.
export const loader = async ({ request, params }: LoaderArgs) => {
  const user = await getUser(request);
  const projectId = "4lfuaunh";
  const dataset = "production";

  const client = createClient({ projectId, dataset, useCdn: true, apiVersion: "2021-10-21" });
  try {
    console.log("getting info");
    const data = await client.fetch(`count(*)`);
    console.log(data);
    console.log("info obtain");
    return data;
  } catch (err) {
    console.error(err);
  }
  const items = await getCalculatorInfo()
  return { user };
};
Jun 5, 2023, 5:36 PM
Glad you figured this out,
user B
, and thank you for posting a solution for others. If you don’t mind, could you please paste your solution into this thread? That really helps to keep each topic focused as well as for us to provide answers, both here and on our website. Thanks!
Jun 5, 2023, 5:54 PM
MOving it
Jun 5, 2023, 5:55 PM
Solved. When using remix blue stack change the exec command from
"dev:server": "cross-env NODE_ENV=development node --inspect --require ./node_modules/dotenv/config --require ./mocks ./build/server.js"
to
"dev:server": "cross-env NODE_ENV=development node --inspect --require ./node_modules/dotenv/config --require ./build/server.js",
Jun 5, 2023, 5:55 PM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?