-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Deno.permissions.querySync is not a function
(Deno Deploy Runtime)
#527
Comments
I think env vars need to be set manually in Deploy. |
I did defined all my variables, the problem does not come from env var, is just the function |
For those encountering the same issue, here is my workaround while waiting this problem is solved on deno side: // Horrible hack in order to fix `Deno.permissions.querySync` not being defined
if (!Deno.permissions.querySync) {
(Deno.permissions as unknown as Record<string, unknown>)["querySync"] = (
_pd: Deno.PermissionDescriptor,
): { state: string } => ({ state: "granted" });
}
// End horrible hack Put it at the first line of your entry-point ;) |
I had the same error while deploying when trying to use Sentry from deno.land
|
I also encountered this with Sentry from Deno.land, I opened an issue on the Sentry-Deno . getsentry/sentry-javascript#10521 |
@carere I am facing the same issue with edgedb. Your hack worked like a charm! Thanks a lot!
|
I believe that Deno Deploy generally doesn't support sync APIs. However, I remember that at some point, |
Do you know if there is any progress on trying to resolve this one Sentry/Deno side? Is there any way I could help to progress with this one? I encountered the same bug which unfortunately makes Sentry not an option for me to use on Deno projects deployed to Deno Deploy. |
it was resolved on sentry side in this release |
This causes problems if the permission isn't available in Deploy though, as it will incorrectly return const permissions = {
run: 'denied',
read: 'granted',
write: 'denied',
net: 'granted',
env: 'granted',
sys: 'denied',
ffi: 'denied',
} as const
Deno.permissions.querySync ??= ({ name }) => {
return {
state: permissions[name],
onchange: null,
partial: false,
addEventListener() {},
removeEventListener() {},
dispatchEvent() {
return false
},
}
} The permission statuses can be regenerated as follows in Deno Deploy playground: Object.fromEntries(
await Promise.all((['run', 'read', 'write', 'net', 'env', 'sys', 'ffi'] as const).map(async (name) => {
try {
return [name, (await Deno.permissions.query({ name })).state]
} catch {
return [name, 'denied']
}
})),
) |
Everything is in the title, I'm deployed an API, and my database is EdgeDB, when I try to establish a connection with it, Edgedb try to read some env var. Thus, it call
Deno.permissions.querySync
, and I get the error highlighted in the title.Here is my stack trace for more info.
It's really annoying, since my API is totally unusable actually...
Is there a way to fix this ? Is this normal ? Should I do something on Deno Deploy ? If yes what ?
Best regards,
The text was updated successfully, but these errors were encountered: