How many reconnections to attempt before giving up
5
confirmationDepth
No
How many confirmations for a transaction to be considered final
6
Considerations ⚠️
Ensure configuration compatibility
Make sure that your client and server confirmationDepth values are compatible.
If your client confirmationDepth is larger than the server's, the confirmed
event will never fire. The client will automatically detect this condition, emit
an error event and disconnect.
If your client's configured network does not match the server's, the client will
emit an error event and disconnect.
If your client heartbeatTimeout is smaller than the server heartbeat interval,
the client will automatically adapt its heartbeat timeout to 2500ms larger than
the server value.
Handle temporary and permanent connection failures
When the connection is interrupted or determined to be stale (no heartbeats
received within the heartbeatTimeout interval), a reconnection attempt will be
made (up to maxReconnects times.)
ChainwebStreamClient is an EventEmitter. You can subscribe to the following
events using .on('event-name', callback).
You can look up named types in src/types.ts.
connect
Emitted when the connection to the backend is first established. Reconnections
to not fire this event, see reconnect instead.
Callback type: () => void
reconnect
Emitted when a reconnection is established. If a connection is dropped or
intentionally killed (e.g. due to staleness/heartbeat timeout) the client will
attempt reconnections at exponential intervals.
Callback type: () => void
confirmed
Emitted when a confirmed transaction is received from the backend. Confirmation
depends on the CONFIRMATION_DEPTH
Callback type: (txn: ITransaction) => void
unconfirmed
Emitted when an unconfirmed transaction is received from the backend. Multiple
unconfirmed events will be fire for the same transaction, as each time the
backend detects a confirmation depth update, it will send the data again with
the latest confirmation depth.
Hint: You can rely on the .meta.id value to de-duplicate the underlying
unconfirmed transactions
Callback type: (txn: ITransaction) => void
heights
Emitted when a heights event is received by the server. This carries the
maximum height as seen from stream-server's corresponding chainweb-data. This
event is mostly intended for calculating minheight when reconnecting, but the
event itself is exposed to users in case they have use cases beyond that, such
as detecting a stalled cw-data.
Developer event emitted whenever anything significant happens. You can attach a
console log to see what is going on internally if you are encountering
unexpected behaviors.
Callback type: (dbg: IDebugMsgObject) => void
FAQs
Chainweb-stream client for browsers and node.js
The npm package @kadena/chainweb-stream-client receives a total of 58 weekly downloads. As such, @kadena/chainweb-stream-client popularity was classified as not popular.
We found that @kadena/chainweb-stream-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.It has 7 open source maintainers collaborating on the project.
Package last updated on 08 Nov 2023
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.