Skip to content

Commit

Permalink
[wasm-client] keeping ownership over 'ReceivedBufferRequestSender' ch…
Browse files Browse the repository at this point in the history
…annel when spawning 'ResponsePusher' (#3945)

* [wasm-client] keeping ownership over 'ReceivedBufferRequestSender' channel when spawning 'ResponsePusher'

* Bump version of Typescript SDK to RC.10

* GitHub Actions workflow to publish SDK to NPM

* Bump package version manually

---------

Co-authored-by: Mark Sinclair <[email protected]>
  • Loading branch information
jstuczyn and mmsinclair authored Oct 3, 2023
1 parent c7da8a7 commit 56a384e
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 37 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/publish-sdk-npm.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish-sdk-npm
name: Publish Typescript SDK
on:
workflow_dispatch:

Expand Down Expand Up @@ -28,8 +28,10 @@ jobs:
- name: Install dependencies
run: yarn

- name: Build and publish
- name: Build WASM and Typescript SDK
run: yarn sdk:build

- name: Publish to NPM
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
working-directory: ./sdk/typescript/packages/sdk
run: scripts/publish.sh
run: ./sdk/typescript/scripts/publish.sh
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/task/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ impl TaskClient {
.await
{
self.log(Level::Error, "Task stopped without shutdown called");
panic!("{timeout}")
panic!("{:?}: {timeout}", self.name)
}
}

Expand Down
2 changes: 1 addition & 1 deletion nym-browser-extension/storage/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "extension-storage"
version = "1.2.0-rc.9"
version = "1.2.0-rc.10"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/nymtech/nym"
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/codegen/contract-clients/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nymproject/contract-clients",
"version": "1.2.0-rc.9",
"version": "1.2.0-rc.10",
"description": "A client for all Nym smart contracts",
"license": "Apache-2.0",
"author": "Nym Technologies SA",
Expand Down
4 changes: 2 additions & 2 deletions sdk/typescript/docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nymproject/ts-sdk-docs",
"version": "1.2.0-rc.9",
"version": "1.2.0-rc.10",
"description": "Nym Typescript SDK Docs",
"license": "Apache-2.0",
"author": "Nym Technologies SA",
Expand Down Expand Up @@ -51,4 +51,4 @@
"typescript": "^4.9.3"
},
"private": false
}
}
2 changes: 1 addition & 1 deletion sdk/typescript/packages/mix-fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nymproject/mix-fetch",
"version": "1.2.0-rc.9",
"version": "1.2.0-rc.10",
"description": "This package is a drop-in replacement for `fetch` to send HTTP requests over the Nym Mixnet.",
"license": "Apache-2.0",
"author": "Nym Technologies SA",
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/packages/node-tester/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nymproject/node-tester",
"version": "1.2.0-rc.9",
"version": "1.2.0-rc.10",
"description": "This package provides a tester that can send test packets to mixnode that is part of the Nym Mixnet.",
"license": "Apache-2.0",
"author": "Nym Technologies SA",
Expand Down
4 changes: 2 additions & 2 deletions sdk/typescript/packages/nodejs-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nymproject/nodejs-client",
"version": "1.2.0-rc.5",
"version": "1.2.0-rc.10",
"license": "Apache-2.0",
"author": "Nym Technologies SA",
"files": [
Expand All @@ -27,7 +27,7 @@
"tsc": "tsc --noEmit true"
},
"dependencies": {
"@nymproject/nym-client-wasm-node": ">=1.2.0-rc.7 || ^1",
"@nymproject/nym-client-wasm-node": ">=1.2.0-rc.10 || ^1",
"comlink": "^4.3.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/packages/sdk-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nymproject/sdk-react",
"version": "1.2.0-rc.9",
"version": "1.2.0-rc.10",
"license": "Apache-2.0",
"author": "Nym Technologies SA",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nymproject/sdk",
"version": "1.2.0-rc.9",
"version": "1.2.0-rc.10",
"license": "Apache-2.0",
"author": "Nym Technologies SA",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion sdk/typescript/packages/validator-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nymproject/nym-validator-client",
"version": "1.2.0-rc.9",
"version": "1.2.0-rc.10",
"description": "A TypeScript client for interacting with smart contracts in Nym validators",
"license": "Apache-2.0",
"author": "Nym Technologies SA (https://nymtech.net)",
Expand Down
8 changes: 1 addition & 7 deletions sdk/typescript/scripts/build-prod-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,4 @@ yarn build:wasm
yarn build:sdk

# build documentation
cd sdk/typescript/docs
npm i
npm run docs:prod:build
cd ../../..

# build examples
pwd
yarn docs:prod:build
2 changes: 1 addition & 1 deletion wasm/client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "nym-client-wasm"
authors = ["Dave Hrycyszyn <[email protected]>", "Jedrzej Stuczynski <[email protected]>"]
version = "1.2.0-rc.9"
version = "1.2.0-rc.10"
edition = "2021"
keywords = ["nym", "sphinx", "wasm", "webassembly", "privacy", "client"]
license = "Apache-2.0"
Expand Down
3 changes: 3 additions & 0 deletions wasm/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ build:
wasm-pack build --scope nymproject --target web --out-dir ../../dist/wasm/client
wasm-opt -Oz -o ../../dist/wasm/client/nym_client_wasm_bg.wasm ../../dist/wasm/client/nym_client_wasm_bg.wasm

build-debug-dev:
wasm-pack build --scope nymproject --target no-modules

build-rust-node:
wasm-pack build --scope nymproject --target nodejs --out-dir ../../dist/node/wasm/client
wasm-opt -Oz -o ../../dist/node/wasm/client/nym_client_wasm_bg.wasm ../../dist/node/wasm/client/nym_client_wasm_bg.wasm
Expand Down
2 changes: 1 addition & 1 deletion wasm/client/internal-dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"webpack-dev-server": "^4.7.4"
},
"dependencies": {
"@nymproject/nym-client-wasm": "file:../../../dist/wasm/client"
"@nymproject/nym-client-wasm": "file:../pkg"
}
}
2 changes: 1 addition & 1 deletion wasm/client/internal-dev/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
patterns: [
'index.html',
{
from: '../../../dist/wasm/client/*.(js|wasm)',
from: '../pkg/*.(js|wasm)',
to: '[name][ext]',
},
],
Expand Down
4 changes: 2 additions & 2 deletions wasm/client/internal-dev/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"

"@nymproject/nym-client-wasm@file:../../../dist/wasm/client":
version "1.2.0-rc.2"
"@nymproject/nym-client-wasm@file:../pkg":
version "1.2.0-rc.9"

"@types/body-parser@*":
version "1.19.2"
Expand Down
11 changes: 10 additions & 1 deletion wasm/client/src/response_pusher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@ use wasm_bindgen::JsValue;
use wasm_bindgen_futures::spawn_local;
use wasm_client_core::client::base_client::ClientOutput;
use wasm_client_core::client::received_buffer::{
ReceivedBufferMessage, ReconstructedMessagesReceiver,
ReceivedBufferMessage, ReceivedBufferRequestSender, ReconstructedMessagesReceiver,
};
use wasm_utils::console_error;

pub(crate) struct ResponsePusher {
reconstructed_receiver: ReconstructedMessagesReceiver,

// we need to keep that channel alive as not to trigger the shutdown
_received_buffer_request_sender: ReceivedBufferRequestSender,

on_message: js_sys::Function,
}

Expand All @@ -36,12 +40,17 @@ impl ResponsePusher {

ResponsePusher {
reconstructed_receiver,
_received_buffer_request_sender: client_output.received_buffer_request_sender,
on_message,
}
}

pub(crate) fn start(mut self) {
spawn_local(async move {
// for some reason if this channel is not explicitly moved into the block,
// it gets dropped when spawning the promise
let _request_sender = self._received_buffer_request_sender;

let this = JsValue::null();

while let Some(reconstructed) = self.reconstructed_receiver.next().await {
Expand Down
2 changes: 1 addition & 1 deletion wasm/full-nym-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "nym-wasm-sdk"
authors = ["Jedrzej Stuczynski <[email protected]>"]
version = "1.2.0-rc.9"
version = "1.2.0-rc.10"
edition = "2021"
keywords = ["nym", "sphinx", "wasm", "webassembly", "privacy"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion wasm/mix-fetch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "mix-fetch-wasm"
authors = ["Jedrzej Stuczynski <[email protected]>"]
version = "1.2.0-rc.9"
version = "1.2.0-rc.10"
edition = "2021"
keywords = ["nym", "fetch", "wasm", "webassembly", "privacy"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion wasm/node-tester/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "nym-node-tester-wasm"
authors = ["Jedrzej Stuczynski <[email protected]>"]
version = "1.2.0-rc.9"
version = "1.2.0-rc.10"
edition = "2021"
keywords = ["nym", "sphinx", "webassembly", "privacy", "tester"]
license = "Apache-2.0"
Expand Down

0 comments on commit 56a384e

Please sign in to comment.