This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kratico
reviewed
Oct 20, 2022
Comment on lines
+38
to
+41
if (rc() == 1) { | ||
const close = await client.close(); | ||
if (close instanceof Error) return close; | ||
} |
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.
I added a couple of console.log
to RpcCall
, rpcClient
and example/watch_blocks
and the output was
root@480c9297b2b1:/workspaces/capi# deno task run test_ctx.ts deno task run examples/watch_blocks.ts
Warning deno task is unstable and may drastically change in the future
Task run deno run -A --no-check=remote "test_ctx.ts" "deno" "task" "run" "examples/watch_blocks.ts"
Check file:///workspaces/capi/test_ctx.ts
Warning deno task is unstable and may drastically change in the future
Task run deno run -A --no-check=remote "examples/watch_blocks.ts"
Check file:///workspaces/capi/examples/watch_blocks.ts
rpc.stdClient
ws.onOpen
result
rpc.stdClient
ws.onOpen
result
rpc.stdClient
result
rpc.stdClient
ws.onOpen
closing..
ws.onOpen
close instanceof Error false
// block data and count == 0
closing..
close instanceof Error false
// block data and count == 1
closing..
close instanceof Error false
// block data and count == 2
rpc.stdClient
ws.onOpen
closing..
close instanceof Error false
It seems that
rpc.stdClient(config)
is invoked many times- as a result
rc() == 1
is always true, that's whyclient.close()
is invoked more than once
This would be the patch for above console.log
entries
diff --git a/effect/RpcCall.ts b/effect/RpcCall.ts
index 8059e3a..465c8f5 100644
--- a/effect/RpcCall.ts
+++ b/effect/RpcCall.ts
@@ -36,7 +36,10 @@ export class RpcCall<
});
}
if (rc() == 1) {
+ console.log("closing..");
const close = await client.close();
+ console.log("close instanceof Error", close instanceof Error);
+ // console.log("result", result);
if (close instanceof Error) return close;
}
// TODO: should this effect implicitly index into `result`?
diff --git a/effect/core/rpcClient.ts b/effect/core/rpcClient.ts
index 742e9f1..8a40f51 100644
--- a/effect/core/rpcClient.ts
+++ b/effect/core/rpcClient.ts
@@ -7,5 +7,6 @@ export function rpcClient<C extends Config>(config: C) {
}
function impl<C extends Config>(config: C) {
+ console.log("rpc.stdClient");
return rpc.stdClient(config);
}
diff --git a/examples/watch_blocks.ts b/examples/watch_blocks.ts
index 29ae6d1..ec8420c 100644
--- a/examples/watch_blocks.ts
+++ b/examples/watch_blocks.ts
@@ -4,7 +4,8 @@ import * as U from "../util/mod.ts";
const root = new C.BlockWatch(C.polkadot, (stop) => {
let i = 0;
return ({ block }) => {
- console.log(block.header);
+ // console.log(block.header);
+ console.log("// block data and count == ", i);
if (i === 2) {
stop();
}
diff --git a/rpc/providers/proxy.ts b/rpc/providers/proxy.ts
index cfbb544..53ceb9c 100644
--- a/rpc/providers/proxy.ts
+++ b/rpc/providers/proxy.ts
@@ -22,6 +22,7 @@ export async function proxyClient<Config_ extends Config<string>>(
pending.resolve(new FailedToOpenConnectionError());
};
const onOpen = () => {
+ console.log("ws.onOpen");
clearListeners();
pending.resolve(client);
};
@@ -68,7 +69,7 @@ export class ProxyClient<Config_ extends Config>
ws.addEventListener("close", onClose);
ws.close();
try {
- await deadline(pending, 250);
+ await deadline(pending, 2500);
} catch (_e) {
pending.resolve(new FailedToDisconnectError());
}
kratico
previously approved these changes
Oct 20, 2022
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.
Let's fix the examples in main
harrysolovay
force-pushed
the
with-zones
branch
from
October 21, 2022 16:14
21aca48
to
1db3de9
Compare
harrysolovay
force-pushed
the
with-zones
branch
from
October 21, 2022 18:20
9d61b52
to
f285e7f
Compare
kratico
approved these changes
Oct 21, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.