Skip to content

docs: note that lazy sessions and multi sessions are mutually exclusive#1292

Open
Dramex wants to merge 2 commits into
grammyjs:mainfrom
Dramex:docs/lazy-session-not-multi
Open

docs: note that lazy sessions and multi sessions are mutually exclusive#1292
Dramex wants to merge 2 commits into
grammyjs:mainfrom
Dramex:docs/lazy-session-not-multi

Conversation

@Dramex

@Dramex Dramex commented Apr 17, 2026

Copy link
Copy Markdown

Closes #936.

The Lazy Sessions section reads as if the middleware has feature parity with strict sessions, but in fact `lazySession` does not accept a `type: "multi"` configuration — on the thread the maintainer confirmed this and that there is no workaround. Until this is documented, users assume they can combine the two and are surprised when it fails.

Adds a short warning callout at the top of the Lazy Sessions section stating the constraint and pointing readers who need multiple session namespaces back to the default strict `session` middleware with `type: "multi"`.

No code changes — docs only, English-language only for now (translations can follow per the usual process).

grammyjs#936 points out that the docs leave readers with the impression that
the lazy-session implementation has feature parity with the strict
session middleware, including multi-session support. It does not — the
maintainer confirmed on the thread that lazy sessions do not accept a
`type: "multi"` configuration and there is no workaround.

Add a warning callout at the top of the Lazy Sessions section stating
the two are mutually exclusive and pointing users who need multi-session
namespaces back to the default `session` middleware with `type: "multi"`.

Closes grammyjs#936.
Comment on lines +644 to +648
::: warning Lazy sessions do not support multi sessions
Lazy sessions and [multi sessions](#multi-sessions) are mutually exclusive.
`lazySession` is a separate implementation of the session middleware, and it does not accept the `type: "multi"` configuration that the strict `session` middleware does.
If you need several independent session namespaces (for example, one per chat and one per user), use the default strict `session` middleware with `type: "multi"`.
:::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes up a bit too much space IMO. What do you think of this?

Suggested change
::: warning Lazy sessions do not support multi sessions
Lazy sessions and [multi sessions](#multi-sessions) are mutually exclusive.
`lazySession` is a separate implementation of the session middleware, and it does not accept the `type: "multi"` configuration that the strict `session` middleware does.
If you need several independent session namespaces (for example, one per chat and one per user), use the default strict `session` middleware with `type: "multi"`.
:::
> Note that the lazy session implementation has no concept of multi sessions.
> Stick with the regular session implementation if you want to use its [multi sessions](#multi-sessions).

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.

Explicitly mention that lazy sessions do not support multi sessions

3 participants