You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.