Skip to content

Conversation

wojpawlik
Copy link
Member

@wojpawlik wojpawlik commented Aug 20, 2020

Description

First step in fixing #914. cc @KnorpelSenf

Currently session has 2 "failure modes":

  1. when getSessionKey(ctx) returns null, session remains unset
  2. when there's no SessionData in store or it's expired, session is set to {}.

I believe changing the latter to also not set session would simplify things. The former behavior can be achieved with ctx.session ??= {} if desired.

I don't care about getting this merged; the typed way to attach (optional) data to ctx is WeakMap / https://yarnpkg.com/package/@emotion/weak-memoize.

How has this been tested?

This code continues passing typecheck:

import session from './session'
import Telegraf from './telegraf'
const bot = new Telegraf('')
bot.use(session())

session.ts itself has one type error that I cannot solve, hence draft.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

@wojpawlik wojpawlik mentioned this pull request Aug 20, 2020
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant