Repository navigation
feat: support @workos-inc/node v12 - #503
Conversation
@workos-inc/node 12 is the first SDK whose feature flag runtime client honors targeting rules that serve false. Accept v11 and v12 as peers. v12 returns user timestamps as Date objects, which the sealed session stores as ISO strings. With v12 installed, turn them back into Date objects when reading a session so the user matches the SDK's User type. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
⚓ Shipyard review suggestionSuggested team: applied-ai, based on recent contributors to the changed files (@nicknisi, @mitch-fultz).
Links open Shipyard for confirmation. Choosing a reviewer overrides availability; “Pick for me” skips known absences. Shipyard Analysis⏳ Generating analysis... ⚓ Explore the analysis in depth in Shipyard · 🔄 Re-run analysis |
|
⚓ Review requested from @gjtorikian for team Shipyard Analysis⏳ Generating analysis... ⚓ Explore the analysis in depth in Shipyard · 🔄 Re-run analysis |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryAdds support for
No actionable issues found. Tests were not run; dependencies are not installed.
|
Why
@workos-inc/node12.0.0 is the first SDK whose feature flag runtime client honors targeting rules that servefalse. Earlier versions ignore those rules, so they returntruefor an excluded user or organization. This package only accepts v9 and v10 as peers, so a Next.js app usinggetFeatureFlagsRuntimeClient()can't get exclusions right. Customers turning on targeting rules are asking for this.^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0, and the dev dependency moves to^12.0.0.Usertimestamps asDateobjects, but the sealed session stores them as ISO strings. Without a change,withAuth().user.createdAtwould be typedDatebut be a string at runtime. With v12 installed, reading a session from the cookie or the middleware header now turnscreatedAt,updatedAtandlastSignInAtback intoDateobjects. With v9 to v11, which type them as strings, sessions are returned unchanged.errorlistener. In v9 to v11, a failed sync with no listener stops all further syncs and can crash the process.false.Proof
Dateproblem: with v12 installed and before thesession.tschange, the existingwithAuthtest failed becausecreatedAtcame back as"2024-01-01T00:00:00.000Z"instead of aDate. It passes after the change.getSessionFromCookietests:Dateobjects.nulllastSignInAtstaysnull.@workos-inc/node10.14.0, then 11.0.0, in place of 12 and ran the whole suite. Each time, only the two tests that assert v12'sDatetimestamps failed, which is expected because those versions type timestamps as strings. All other 494 tests passed, including keyless mode and feature flags.errorlistener claim: 9.3.1, 10.0.0, 10.14.0 and 11.0.0 all callemit("error")in the poll loop without checking for a listener. On 10.14.0, a first sync that failed with a 500 crashed a plain Node process with an unhandledGenericServerException. With the rejection caught, polling still never resumed, and flags never loaded even though the next poll would have succeeded. With the README's listener, the client retried and loaded flags. v12 checks for a listener first (fix(feature-flags): Keep polling when no error listener is attached workos-node#1728).Not proven
I haven't run this in a real Next.js app against a WorkOS environment. To check it, run an app with
WORKOS_*credentials on@workos-inc/node12 and confirm:withAuth().user.createdAt instanceof Dateis true.getFeatureFlagsRuntimeClient()polls/sdk/feature-flags?payload_version=2and returnsfalsefor a user excluded by a rule that servesfalse.🤖 Generated with Claude Code