TristanT
Convex Communityโ€ข3y agoโ€ข
5 replies
Tristan

Convex Client not exiting cleanly

I'm having trouble getting InternalConvexClient to exit cleanly. The following code hangs, even though I call client.close(). Am I missing something?
import { InternalConvexClient } from "convex/browser";
import WebSocket from "ws";

const url = "https://mellow-meerkat-454.convex.cloud";
const client = new InternalConvexClient(url, (queries) => {}, {
  webSocketConstructor: WebSocket as any,
  unsavedChangesWarning: false,
});

// Close after waiting a bit to ensure client has connected.
setTimeout(() => {
  client.close().then(() => console.log("resolved client.close()"));
}, 2000);

process.on("exit", () => {
  console.log("clean exit");
});
Was this page helpful?