Skip to content
Snippets Groups Projects
Unverified Commit 6d5f8141 authored by Tarek Mohamed Abdalla's avatar Tarek Mohamed Abdalla Committed by GitHub
Browse files

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: default avatarNiklas Adolfsson <niklasadolfsson1@gmail.com>
parent 41b6915e
Branches
No related merge requests found
Pipeline #506915 waiting for manual action with stages
in 1 hour, 26 minutes, and 10 seconds
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
title: "rpc server: fix subscription id_provider being reset to default one"
doc:
- audience: Node Dev
description: |
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.
crates:
- name: sc-rpc-server
bump: patch
\ No newline at end of file
......@@ -144,7 +144,7 @@ where
local_addrs.push(local_addr);
let cfg = cfg.clone();
let mut id_provider2 = id_provider.clone();
let id_provider2 = id_provider.clone();
tokio_handle.spawn(async move {
loop {
......@@ -197,10 +197,9 @@ where
.set_http_middleware(http_middleware)
.set_message_buffer_capacity(max_buffer_capacity_per_connection)
.set_batch_request_config(batch_config)
.custom_tokio_runtime(cfg.tokio_handle.clone())
.set_id_provider(RandomStringIdProvider::new(16));
.custom_tokio_runtime(cfg.tokio_handle.clone());
if let Some(provider) = id_provider2.take() {
if let Some(provider) = id_provider2.clone() {
builder = builder.set_id_provider(provider);
} else {
builder = builder.set_id_provider(RandomStringIdProvider::new(16));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment