Skip to content
This repository was archived by the owner on Jul 14, 2026. It is now read-only.
This repository was archived by the owner on Jul 14, 2026. It is now read-only.

StoreSession breaks on Windows when sessionName is an absolute path #835

Description

@Minecraft9101010

On Windows, StoreSession fails to load an existing session when sessionName is an absolute path (e.g. C:\Users\me.telegram\session). The cause is in gramjs/sessions/StoreSession.ts, in the constructor:

this.store = store.area(
sessionName,
new LocalStorage("./" + sessionName)
);
It unconditionally prepends "./" to sessionName. When the name is already an absolute path, this produces a malformed path like ./C:\Users\me.telegram\session, so node-localstorage reads/writes the wrong directory and the saved session is never found. The user gets logged out every run.

The fix is to only prepend "./" for relative paths:

const path = require("path");
this.store = store.area(
sessionName,
new LocalStorage(path.isAbsolute(sessionName) ? sessionName : "./" + sessionName)
);
(path can be hoisted to a top-of-file import if preferred.) This leaves the existing relative-path behavior untouched and fixes absolute paths on all platforms. Happy to open a PR if that's easier.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions