Closed bdodroid closed 11 months ago
Can you please share the full snippet?
The full snippet of the code? its the getAndDeleteOAuthSession() in the lib/_kv.ts file of this repo
or the error log?
Error: Failed to delete OAuth session
at getAndDeleteOAuthSession (c:\Users\Documents\projects\x\deno_kv_oauth@v0.10.0\lib\https:\deno.land\x\deno_kv_oauth@v0.10.0\lib\_kv.ts:67:28)
at eventLoopTick (C:\Users\Documents\projects\ore\01_core.js:165:11)
at async handleCallback (C:\Users\Documents\projects\x\deno_kv_oauth@v0.10.0\lib\handle_callback.ts:67:24)
at async handler (c:\Users\Documents\projects\main.ts:42:28)
at async respond (ext:deno_http/01_http.js:566:16) {stack: 'Error: Failed to delete OAuth session
at …ync respond (ext:deno_http/01_http.js:566:16)', message: 'Failed to delete OAuth session', __callSiteEvals: Array(5)}
or my main.ts?
import {
createAuth0OAuthConfig,
getSessionId,
handleCallback,
signIn,
signOut,
} from "https://deno.land/x/deno_kv_oauth@v0.10.0/mod.ts";
const oauthConfig = createAuth0OAuthConfig({redirectUri: "http://localhost:3000/oauth/callback", scope: "openid profile email"});
async function handler(request: Request) {
const { pathname } = new URL(request.url);
switch (pathname) {
case "/oauth/signin":
return await signIn(request, oauthConfig);
case "/oauth/callback":
const { response } = await handleCallback(request, oauthConfig);
return response;
case "/oauth/signout":
return await signOut(request);
case "/protected-route":
return await getSessionId(request) === undefined
? new Response("Unauthorized", { status: 401 })
: new Response("You are allowed");
default:
return new Response(null, { status: 404 });
}
}
Deno.serve({port: 3000}, handler);
I created an Auth0 account and successfully signed in without issue. I wasn't able to reproduce the issue.
I can't say, with confidence, why the commit within getAndDeleteOAuthSession()
is failing. Unfortunately, KV doesn't yet provide much insight into why commits fail, but there's work in progress that should fix that.
Can you please share your deno --version
output? Also, has this only happened once or does this happen repeatedly?
Version: deno 1.37.1 (also tried updating to 1.38.3 just barely, same result) on windows if that matters?
Its really weird. It happens every time.
I ended up just doing "deno vendor main.ts" and created an import map to the local files and commented out line 42 in the _kv.ts
// if (!res.ok) throw new Error("Failed to delete OAuth session");
and everything is working fine for me in testing. Obviously not great, but at least I can test some stuff.
I'll try it on another pc and maybe just push it to a deno.deploy instance and see if it's just something weird with my environment.
Try this:
demo.ts
to use createAuth0OAuthConfig()
how you likedeno task demo
But yes, please let me know how you go on Deploy and the other machine.
Looks like it is an issue with my setup on my windows environment.
Just tried it on my debian laptop with the same exact code (and deno version) and it ran fine, and my deploy to deno.deploy is working just fine as well.
Not sure what my issue is on windows.
Appreciate your help @iuioiua !
Oh, that's good to hear. Thanks for bringing this up! Glad I could be of assistance.
Everything seems fine until it tries to delete the KV entry
at which point it throws
I am running with --unstable and --allow-all.
No idea why this is failing. My keys and domain are set for Auth0 and Auth0 is configured to point everything to my localhost.