Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Make JavaScript HTTP connection emit timeout event #3

Merged
merged 1 commit into from
Mar 14, 2022

Conversation

alaynarichmond
Copy link
Member

The JavaScript HttpConnection allows the caller to set a request timeout via the nodeOptions property. However, neither the connection object nor the thrift client provides a way for the caller to know when a timeout occured. With this change, the HttpConnection will now emit a timeout event when an underlying NodeJS timeout event occurs. A caller can add an event listener to the connection as follows:

const thrift = require('thrift');
const connection = thrift.createHttpConnection('localhost', 1234, {
  nodeOptions: {
    timeout: 1000
  }
});
connection.on();
connection.on('timeout', () => {
  console.log('Request timed out after 1000ms');
});

@alaynarichmond alaynarichmond requested a review from Fluxx March 14, 2022 20:25
@alaynarichmond alaynarichmond force-pushed the ar/http-transport-timeout branch from 1c2aaeb to bdeea5c Compare March 14, 2022 20:35
The JavaScript `HttpConnection` allows the caller to set a request timeout via the `nodeOptions` property. However, neither the HTTP connection nor the thrift client provides a way for the caller to know when a timeout occured. With this change, the `HttpConnection` will now emit a timeout event when the NodeJS timeout event occurs. A caller can add an event listener to the connection as follows:

```
const thrift = require('thrift');
const connection = thrift.createHttpConnection('localhost', 1234, {
  nodeOptions: {
    timeout: 1000
  }
});
connection.on();
connection.on('timeout', () => {
  console.log('Request timed out after 1000ms');
});
```
@alaynarichmond alaynarichmond force-pushed the ar/http-transport-timeout branch from bdeea5c to fd0e320 Compare March 14, 2022 20:36
@alaynarichmond alaynarichmond merged commit 0c78794 into master Mar 14, 2022
@alaynarichmond alaynarichmond deleted the ar/http-transport-timeout branch March 14, 2022 21:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants