-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add keep alive to Filter #1970
Conversation
… mapping default for decoder / encoder
Draft for now before #1958 is merged. |
size-limit report 📦
|
packages/sdk/src/protocols/filter.ts
Outdated
return; | ||
} | ||
|
||
this.keepAliveTimer = window.setInterval(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using window
here might be limiting and could cause breaking API in nodejs env
I think just using setInterval
/clearInterval
should implicitly polyfill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, the reason why I went with window
is to make typescript understand that it is browser
API, otherwise I need to suppress types
making it using API directly with type trick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise I need to suppress types
the types natively exist in TypeScript -- no need to supress types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is an ambiguity in types
in nodejs
it returns NodeJS.Timeout
- https://github.com/DefinitelyTyped/DefinitelyTyped/blob/778ad7a80e9876f258270d84d1db4e6e1d5e3796/types/node/timers.d.ts#L191
where as in browser it is a number
hence the need to do as number
to help TS determine it is browser interface
Why can't we use the existing keep alive manager for this? Or why is it insufficient? |
This is because |
Problem
Filter doesn't keep keep subscription forever and requires periodic pings.
Solution
Implement
keep alive
feature to do automatic pings to the peers.Notes