Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,40 @@ main().then(() => {

</details>

<details>
<summary>AbortController</summary>

```javascript
import { RequestManager, Client, HTTPTransport, AbortError } from "@open-rpc/client-js";

const transport = new HTTPTransport("http://localhost:3333");
const requestManager = new RequestManager([transport]);
const client = new Client(requestManager);

const main = async () => {
const controller = new AbortController();
const signal = controller.signal;

setTimeout(() => {
controller.abort();
}, 100);

try {
await client.request({ method: "long_running_method", params: [] }, { timeout: 5000, signal });
} catch (e) {
if (e instanceof AbortError) {
console.log("Request was aborted");
} else {
console.error(e);
}
}
};

main();
```

</details>

### Building

```sh
Expand Down
1 change: 1 addition & 0 deletions bun.lock

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

Loading