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

Uncaught Exception "Deno.permissions.querySync is not a function" on Deno Deploy

Open igorbdl opened this issue 1 year ago • 1 comments

Describe the bug When trying to use the client library on Deno Deploy, there is the following error:

TypeError: Deno.permissions.querySync is not a function
    at getEnv (https://deno.land/x/[email protected]/_src/adapter.shared.deno.ts:3:36)
    at parseConnectDsnAndArgs (https://deno.land/x/[email protected]/_src/conUtils.ts:504:21)
    at ClientPool._parseConnectArguments (https://deno.land/x/[email protected]/_src/conUtils.ts:99:17)
    at ClientPool._getNormalizedConnectConfig (https://deno.land/x/[email protected]/_src/baseClient.ts:364:46)
    at ClientPool.getNewConnection (https://deno.land/x/[email protected]/_src/baseClient.ts:375:31)
    at ClientConnectionHolder._getConnection (https://deno.land/x/[email protected]/_src/baseClient.ts:62:43)
    at ClientConnectionHolder.retryingFetch (https://deno.land/x/[email protected]/_src/baseClient.ts:175:31)
    at ClientConnectionHolder.query (https://deno.land/x/[email protected]/_src/baseClient.ts:219:17)
    at Client.query (https://deno.land/x/[email protected]/_src/baseClient.ts:594:27)
    at async file:///src/main.ts:5:16

Reproduction Include the code that is causing the error:

import { createClient } from "https://deno.land/x/edgedb/mod.ts";

const client = createClient();

const result = await client.query("select 2 + 2");

console.log(result);

Deno.serve((req: Request) => new Response("It works!"));

Expected behavior Being able to use the client library on Deno Deploy.

Additional context Sentry had a similar issue with Deno Deploy which was fixed here.

It is possible to workaround the issue on Deno Deploy with this hack, but it would be much better if resolved on the library.

igorbdl avatar Oct 30 '24 12:10 igorbdl

Thanks for the bug report here! I'm a little bit annoyed that this well-documented, non-deprecated Deno API is not supported on Deno Deploy 😓 This means you would not be able to use environment variables to configure the connection which is our suggested way of doing client connection configuration in a production environment, so I don't really want to follow the way Sentry fixed this. However, it might be possible to use the async version with some general refactoring, so we'll take a look at that (PRs welcome!)

scotttrinh avatar Oct 31 '24 00:10 scotttrinh