Comments (7)
From experience: It worked fine with async stuff for me. But forgetting the await on something is easily done in JavaScript / TypeScript. There are some ESLints that help with finding that in TypeScript.
Personally I switched away towards grammY. It provides its own session logic and the storage is separated from the middleware logic which prevents implementation bugs there. It might be worth a look. Switching from Telegraf to grammY is relatively straight forward and grammYs documentation is way better.
from telegraf-session-local.
Here is the example vtcaregorodtcev/remark-telegram-bot@dde683b#diff-5566f90f142be7d5c358410953f0b4c628c99e20b620d172c8e12ec92bdc9620R34
at 34 line I use sync middleware to save Link to the session
at 35 I use async middleware to get data from the Link
at 36 line I can get async data only within the same user message if the user will send another message, I lost data from 35 line.
from telegraf-session-local.
from telegraf-session-local.
@EdJoPaTo it's also worth mentioning, my example is based on AWS setup
from telegraf-session-local.
AWS should be completely irrelevant here. Node.js is Node.js and its async/await Logic is handled the same way on all platforms. Whatever the exact problem is, you should be able to reproduce it locally. When that is possible throw out stuff in order to have a minimal example where you can still reproduce the bug. Then its way easier to find the cause of it.
What helps me with missing awaits somewhere: Create a simple logging middleware and put it in between every other middleware. If a log message comes before it should, there is a missing await.
Maybe check out my console.time middleware for testing middlewares. If the inner is way to short or the report comes back way to early the problem is below of what you tested. If the before/after is way to short, then its the middleware you just checked.
from telegraf-session-local.
@EdJoPaTo sorry, it looks like I should anyway set up all AWS flow for minimal reproduction. I guess you can fork provided commit vtcaregorodtcev/remark-telegram-bot@dde683b and there is an issue.
there is Link property which set in sync manner vtcaregorodtcev/remark-telegram-bot@dde683b#diff-4219770533d72f642405c1221b67774ae414f90ab05212b8b44bb2b063b62cf9R15
and Text property which set in async manner vtcaregorodtcev/remark-telegram-bot@dde683b#diff-a2fb86f8d1743026e193802adeb45a908d8793046564073b63e6dcc1feade4c2R31
if we will set console.log or something here vtcaregorodtcev/remark-telegram-bot@dde683b#diff-5566f90f142be7d5c358410953f0b4c628c99e20b620d172c8e12ec92bdc9620R32
we will see that after each request Link is still stay but Text is missing.
to run it locally we should anyway deploy lambda to AWS to use offline serverless.
pnpm deploy
then get lamda URL and TOKEN=your_bot_token HOOK=lambda_url pnpm start
from telegraf-session-local.
Thanks for help @EdJoPaTo 👍
Closing now as stale, but if someone wanna ask more - feel free to do so.
from telegraf-session-local.
Related Issues (20)
- created session value is missing on the "poll_answer" ctx HOT 1
- Problem with types HOT 8
- can't find module telegraf-session HOT 2
- Typo in the full example HOT 5
- How to use this session local with Scene HOT 2
- issue with nodemon HOT 2
- Is it possible to change a user session? HOT 2
- session doesn't save to file with latest telegraf version > 4.8 HOT 2
- Is it possible to set an expiration time to a session? HOT 3
- telegraf-session-local kills my server when i am trying to connect session middleware HOT 4
- How many concurrent users this library can handle? HOT 3
- session is not saved inside Promise.then HOT 4
- Cannot find module './lodash-id.js HOT 2
- Save a session on bot start? HOT 3
- Session doesn't updated in 2nd middleware in row HOT 2
- Typescript typings
- Error with Session version 1.0.3 with telegraf-js v 3.38 HOT 1
- Property 'session' does not exist on type 'TelegrafContext' HOT 2
- Not all data is saved in a local file HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegraf-session-local.