Skip to content

fix(templates): repair registration in the Fastify starter - #34

Merged
Bccorb merged 1 commit into
mainfrom
fix/fastify-template-cookie-ttl
Jul 31, 2026
Merged

fix(templates): repair registration in the Fastify starter#34
Bccorb merged 1 commit into
mainfrom
fix/fastify-template-cookie-ttl

Conversation

@Bccorb

@Bccorb Bccorb commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Fixes the 500 you hit registering against the scaffolded Fastify API.

ERROR: TypeError: option maxAge is invalid: 300
    at Module.stringifySetCookie (/app/node_modules/cookie/src/index.ts:305:13)
    at serialize (/app/node_modules/@fastify/cookie/index.js:16:23)

Cause

The auth server sends the registration response's ttl as the string "300". cookie checks Number.isInteger, which a string fails. The Express starter never showed this because its adapter does maxAge: seconds * 1000, and the multiply coerces the string to a number.

@seamless-auth/core 0.12.1 (fells-code/seamless-auth-server#145) parses the lifetime before it reaches an adapter, so the starter is fixed without waiting on the auth server to start sending a number. That server-side fix is fells-code/seamless-auth-api#138, still unreleased, and this template does not need it.

What actually fixes it here

The lockfile, not the version range. @seamless-auth/fastify 0.3.0 already ranged core at ^0.12.0, so a fresh resolve would have picked up 0.12.1 on its own. But the committed lockfile pinned core 0.12.0, and that is what a scaffolded project installs. I confirmed this: installing @seamless-auth/fastify@0.3.0 today still resolves core 0.12.1 and works.

The pin moves to ^0.3.1 because that is the release carrying the changeset, but the functional change is core 0.12.0 -> 0.12.1 in the lockfile.

Verification

Beyond npm run validate, npm run build, and npm run lint, I drove the adapter directly with the response the auth server actually sends today (a string ttl) through /auth/registration/register:

State Result
Committed lockfile (core 0.12.0) 500, option maxAge is invalid: 300
This branch (core 0.12.1) 200, Set-Cookie with Max-Age=300

So the reported failure reproduces exactly on main and is gone here.

Express starter left alone

It is on @seamless-auth/express ^0.12.0 with core 0.12.0 locked, and it was never broken by this, since its adapter coerced the string. Refreshing its lockfile onto core 0.12.1 is tidy but not a fix, so I left it out rather than widen a bug fix. Happy to do it separately.

Registering against the scaffolded API returned a 500 with
`TypeError: option maxAge is invalid: 300`. The auth server sends the
registration response's ttl as the string "300", and the Fastify adapter passes
it to a cookie library that requires an integer. The Express starter never
showed this: its adapter multiplies the value into milliseconds, which coerces
the string.

@seamless-auth/core 0.12.1 parses the lifetime before an adapter sees it, so the
starter is fixed without waiting on the auth server to send a number. It arrives
here through @seamless-auth/fastify 0.3.1.

The lockfile is the functional part. @seamless-auth/fastify 0.3.0 already ranged
core at ^0.12.0, so a fresh resolve would have picked up the fix, but the
committed lockfile pinned core 0.12.0 and that is what a scaffolded project
installed.

Verified by driving the adapter with the response the auth server actually
sends today, a string ttl, through /auth/registration/register. On the committed
lockfile that reproduces the reported 500 exactly; after this change it returns
200 with Max-Age=300. Plus npm run validate, npm run build, and npm run lint.
@Bccorb
Bccorb merged commit ad7d7c6 into main Jul 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant