devondragon / workers-users

Cloudflare Workers based User Management and Session State Framework
Apache License 2.0
35 stars 8 forks source link

Session-state threw an exception #22

Closed agenio closed 4 months ago

agenio commented 4 months ago

Hello,

i'm trying to use your awesome project to manage users into a my project. I have an issue with the session-state worker that continue to threw this exeception:

{ "truncated": false, "outcome": "exception", "scriptVersion": { "id": "c9960f47-24a5-4932-9e5c-4edf4a796bfe" }, "scriptName": "session-state", "diagnosticsChannelEvents": [], "exceptions": [ { "name": "TypeError", "message": "Callback returned incorrect type; expected 'Promise'", "timestamp": 1721583387361 } ], "logs": [], "eventTimestamp": 1721583387343, "event": { "request": { "url": "https://session-state.d1.compact.workers.dev/create", "method": "POST", "headers": { "content-type": "application/json" } } }, "id": 0 }

create-issue-branch[bot] commented 4 months ago

Branch issue-22-Session-state-threw-an-exception created!

devondragon commented 4 months ago

@agenio - sorry about that, I will take a look. Probably related to recent changes I made.

agenio commented 4 months ago

Don't worry it's part of the job.

I found a possible fix, i changed: export default { fetch: router.handle, }; to export default router;

into index.ts (session-state package) and now the exception isn't threw and session management works

devondragon commented 4 months ago

Yeah it's due to this issue:

https://itty.dev/itty-router/guides/cloudflare-workers https://github.com/cloudflare/workers-sdk/issues/5420

I'm about to push a fix (which includes some other code cleanup and refactoring to better align with the other packages.

devondragon commented 4 months ago

Fix for this and some refactoring and improvements pushed and PR'ed to main. Thanks!