Skip to content

Commit 39df704

Browse files
committed
doc: Bumped changelog & improved streams errors
1 parent 6db20ce commit 39df704

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

changelog.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
1.6.2
2+
-----
3+
- Feat: Streams do now support auto-reconnection for the initial connection attempt
4+
15
1.6.1
26
-----
3-
- Feat: New option for creating streams, `autoConnect` that is `true` by default. Setting the value to `false` will cause the `TweetStream` object to be returned immediately (not in a `Promise`), because connection isn't awaited. #92
4-
- Fix: `autoReconnectRetries`: Setting this params to `Infinity` no longer causes the stream reconnection attempts to be delayed to next event loop turn. #92
5-
- Fix: Use `https.request(options)` instead of `https.request(url, options)`, because some people has outdated dependencies that overwrite native Node's exported function and break its signature. #94 #96
6-
- Feat: Next retry timeout computation can be customized by using `.nextRetryTimeout` property of `TweetStream` instance, that is function taking a `tryOccurence` and returning the number of milliseconds to wait before trying to reconnect.
7+
- Feat: New option for creating streams, `autoConnect` that is `true` by default ; Setting the value to `false` will cause the `TweetStream` object to be returned immediately (not in a `Promise`), because connection isn't awaited #92
8+
- Fix: `autoReconnectRetries`: Setting this params to `Infinity` no longer causes the stream reconnection attempts to be delayed to next event loop turn #92
9+
- Fix: Use `https.request(options)` instead of `https.request(url, options)`, because some people has outdated dependencies that overwrite native Node's exported function and break its signature #94 #96
10+
- Feat: Next retry timeout computation can be customized by using `.nextRetryTimeout` property of `TweetStream` instance, that is function taking a `tryOccurence` and returning the number of milliseconds to wait before trying to reconnect
711

812
1.6.0
913
-----

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twitter-api-v2",
3-
"version": "1.6.1",
3+
"version": "1.6.2",
44
"description": "Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/stream/TweetStream.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface ITweetStreamError {
1010
type: ETwitterStreamEvent.ConnectionError | ETwitterStreamEvent.TweetParseError
1111
| ETwitterStreamEvent.ReconnectError | ETwitterStreamEvent.DataError | ETwitterStreamEvent.ConnectError;
1212
error: any;
13+
message?: string;
1314
}
1415

1516
export interface IConnectTweetStreamParams {
@@ -85,6 +86,7 @@ export class TweetStream<T = any> extends EventEmitter {
8586
this.emit(ETwitterStreamEvent.Error, {
8687
type: ETwitterStreamEvent.ConnectionError,
8788
error: err,
89+
message: 'Connection lost or closed by Twitter.',
8890
});
8991

9092
this.onConnectionError();
@@ -115,7 +117,11 @@ export class TweetStream<T = any> extends EventEmitter {
115117
this.parser.on(EStreamParserEvent.ParsedData, (eventData: any) => {
116118
if (payloadIsError && payloadIsError(eventData)) {
117119
this.emit(ETwitterStreamEvent.DataError, eventData);
118-
this.emit(ETwitterStreamEvent.Error, { type: ETwitterStreamEvent.DataError, error: eventData });
120+
this.emit(ETwitterStreamEvent.Error, {
121+
type: ETwitterStreamEvent.DataError,
122+
error: eventData,
123+
message: 'Twitter sent a payload that is detected as an error payload.',
124+
});
119125
}
120126
else {
121127
this.emit(ETwitterStreamEvent.Data, eventData);
@@ -127,6 +133,7 @@ export class TweetStream<T = any> extends EventEmitter {
127133
this.emit(ETwitterStreamEvent.Error, {
128134
type: ETwitterStreamEvent.TweetParseError,
129135
error,
136+
message: 'Failed to parse stream data.',
130137
});
131138
});
132139
}
@@ -238,7 +245,8 @@ export class TweetStream<T = any> extends EventEmitter {
238245
this.emit(ETwitterStreamEvent.ConnectError, 0);
239246
this.emit(ETwitterStreamEvent.Error, {
240247
type: ETwitterStreamEvent.ConnectError,
241-
error: new Error(`Connect error - Initial connection just failed.`),
248+
error: e,
249+
message: 'Connect error - Initial connection just failed.',
242250
});
243251

244252
this.makeAutoReconnectRetry(0);
@@ -296,7 +304,8 @@ export class TweetStream<T = any> extends EventEmitter {
296304
this.emit(ETwitterStreamEvent.ReconnectError, retryOccurence);
297305
this.emit(ETwitterStreamEvent.Error, {
298306
type: ETwitterStreamEvent.ReconnectError,
299-
error: new Error(`Reconnect error - ${retryOccurence + 1} attempts made yet.`),
307+
error: e,
308+
message: `Reconnect error - ${retryOccurence + 1} attempts made yet.`,
300309
});
301310

302311
this.makeAutoReconnectRetry(retryOccurence);

0 commit comments

Comments
 (0)