Sveltekit + surrealdb-adapter + email magic link login does not work
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- node.js, typescript
- Domain
- authentication
Research direction
Clone the reproduction repository and follow README.md to configure the environment, start SurrealDB, and run the SvelteKit development server. Reproduce the magic-link login and inspect the @auth/core/lib/utils/web.js stack entry alongside the adapter session data. Done means the callback completes without the expires error, a login cookie is saved, and the user is logged in.
Written by the indexing model from the issue text.
Description
Environment
System:
OS: Linux 6.5 Pop!_OS 22.04 LTS
CPU: (12) x64 AMD Ryzen 5 5625U with Radeon Graphics
Memory: 8.56 GB / 14.97 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 20.2.0 - ~/.asdf/installs/nodejs/20.2.0/bin/node
npm: 9.6.6 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 8.12.1 - ~/.local/share/pnpm/pnpm
bun: 0.7.3 - ~/.bun/bin/bun
Browsers:
Chromium: 120.0.6099.71
npmPackages:
@auth/core: ^0.19.0 => 0.19.0
@auth/surrealdb-adapter: ^0.2.6 => 0.2.6
@auth/sveltekit: ^0.5.0 => 0.5.0
Reproduction URL
https://github.com/Z-snails/authjs-email-error
Describe the issue
When signing in with email, after clicking the sign in link in the email, the following error occurs (with full log of a sign in)
[auth][error] TypeError: option expires is invalid
[auth][warn][debug-enabled] Read more: https://warnings.authjs.dev#debug-enabled
[auth][debug]: adapter_getUserByEmail {
"args": [
"<my email>"
]
}
[auth][debug]: adapter_createVerificationToken {
"args": [
{
"identifier": "<my email>",
"token": "...",
"expires": "2023-12-23T09:40:26.862Z"
}
]
}
[auth][debug]: adapter_useVerificationToken {
"args": [
{
"identifier": "<my email>",
"token": "..."
}
]
}
[auth][debug]: adapter_getUserByEmail {
"args": [
"<my email>"
]
}
[auth][debug]: adapter_getUserByEmail {
"args": [
"<my email>"
]
}
[auth][debug]: adapter_updateUser {
"args": [
{
"id": "⟨b204504e-3d69-4dbb-af93-9b5cddcabcdc⟩",
"emailVerified": "2023-12-22T09:40:40.114Z"
}
]
}
[auth][debug]: adapter_createSession {
"args": [
{
"sessionToken": "...",
"userId": "⟨b204504e-3d69-4dbb-af93-9b5cddcabcdc⟩",
"expires": "2024-01-21T09:40:40.115Z"
}
]
}
[auth][error] TypeError: option expires is invalid
at serialize (~/auth-test/node_modules/.pnpm/cookie@0.6.0/node_modules/cookie/index.js:161:13)
at ~/auth-test/node_modules/.pnpm/@auth+core@0.19.0_nodemailer@6.9.7/node_modules/@auth/core/lib/utils/web.js:76:30
at Array.forEach (<anonymous>)
at toResponse (~/auth-test/node_modules/.pnpm/@auth+core@0.19.0_nodemailer@6.9.7/node_modules/@auth/core/lib/utils/web.js:74:18)
at Module.Auth (~/auth-test/node_modules/.pnpm/@auth+core@0.19.0_nodemailer@6.9.7/node_modules/@auth/core/index.js:107:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Module.respond (~/auth-test/node_modules/.pnpm/@sveltejs+kit@2.0.6_@sveltejs+vite-plugin-svelte@3.0.1_svelte@4.2.8_vite@5.0.10/node_modules/@sveltejs/kit/src/runtime/server/respond.js:291:20)
at async ~/auth-test/node_modules/.pnpm/@sveltejs+kit@2.0.6_@sveltejs+vite-plugin-svelte@3.0.1_svelte@4.2.8_vite@5.0.10/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:502:22
q
How to reproduce
- Clone the github repo (https://github.com/Z-snails/authjs-email-error)
- Install the deps (with
pnpm installornpm install) - See
README.mdfor how to configure.env(I used sendgrid as the email server) - Start the surreal server with
surreal start(helpful to use tmux or similar) - Start the dev server
npm dev - Open in browser
- Click Sign In
- Enter email address
- Click on link in email
Expected behavior
I should be logged in and a login cookie should be saved in my browser. Neither of these occur, instead an error 500 is returned.
Although the user shows as verified in the database.
- Dominant language
- TypeScript
- Stars
- 28.4k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nextauthjs/next-auth
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
nextauthjs/next-auth#13495 ·
-
triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
nextauthjs/next-auth#13483 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
nextauthjs/next-auth#13475 ·
-
triage
Difficulty 1/5 Under an hour Newbie friendliness 88/100
nextauthjs/next-auth#13472 ·
-
bug triage
Difficulty 1/5 Under an hour Newbie friendliness 68/100
nextauthjs/next-auth#13204 ·
All issues in nextauthjs/next-auth
Similar issues
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 76/100
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
vercel/react-tweet#225 ·