Skip to content

Commit 6d5f814

Browse files
TarekkMAniklasad1
andauthored
rpc server: fix subscription id_provider being reset to default one. (#6588)
# Description The PR ensures that the id_provider variable is cloned instead of taken, which can help prevent issues related id provider being reset to the default. In [a test in moonbeam](https://github.com/moonbeam-foundation/moonbeam/blob/c6d07d703dfcdd94cc311fa83b553071b7d433ff/test/suites/dev/moonbase/test-subscription/test-subscription.ts#L20-L31) we found that the id_provider is being reset somehow and changed to the default one. Changing .take() to .clone() would fix the issue. # Checklist * [x] My PR includes a detailed description as outlined in the "Description" and its two subsections above. * [ ] My PR follows the [labeling requirements]( https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Process ) of this project (at minimum one label for `T` required) * External contributors: ask maintainers to put the right label on your PR. * [ ] I have made corresponding changes to the documentation (if applicable) * [ ] I have added tests that prove my fix is effective or that my feature works (if applicable) --------- Co-authored-by: Niklas Adolfsson <[email protected]>
1 parent 41b6915 commit 6d5f814

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

prdoc/pr_6588.prdoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
2+
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
3+
4+
title: "rpc server: fix subscription id_provider being reset to default one"
5+
6+
doc:
7+
- audience: Node Dev
8+
description: |
9+
The modification ensures that the id_provider variable is cloned instead of taken, which can help prevent issues related id provider being reset to the default.
10+
11+
12+
crates:
13+
- name: sc-rpc-server
14+
bump: patch

substrate/client/rpc-servers/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ where
144144
local_addrs.push(local_addr);
145145
let cfg = cfg.clone();
146146

147-
let mut id_provider2 = id_provider.clone();
147+
let id_provider2 = id_provider.clone();
148148

149149
tokio_handle.spawn(async move {
150150
loop {
@@ -197,10 +197,9 @@ where
197197
.set_http_middleware(http_middleware)
198198
.set_message_buffer_capacity(max_buffer_capacity_per_connection)
199199
.set_batch_request_config(batch_config)
200-
.custom_tokio_runtime(cfg.tokio_handle.clone())
201-
.set_id_provider(RandomStringIdProvider::new(16));
200+
.custom_tokio_runtime(cfg.tokio_handle.clone());
202201

203-
if let Some(provider) = id_provider2.take() {
202+
if let Some(provider) = id_provider2.clone() {
204203
builder = builder.set_id_provider(provider);
205204
} else {
206205
builder = builder.set_id_provider(RandomStringIdProvider::new(16));

0 commit comments

Comments
 (0)