Skip to content

Commit

Permalink
prevent user errors in watcher event listeners from causing backoffs …
Browse files Browse the repository at this point in the history
…in the underlying stream
  • Loading branch information
connor4312 committed Nov 28, 2020
1 parent 69129eb commit cead70a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.1.0 TBA

- **fix:** buffers not allowed in typings `Namespace.get(<key>)`
- **fix:** prevent user errors in watcher event listeners from causing backoffs in the underlying stream

## 1.0.2 2020-09-18

Expand All @@ -25,14 +26,14 @@

```js
const etcd3 = new Etcd3({
defaultCallOptions: context => context.isStream ? {} : Date.now() + 10000,
defaultCallOptions: context => (context.isStream ? {} : Date.now() + 10000),
});
```

The default options are shallow merged with any call-specific options. For example this will always result in a 5 second timeout, regardless of what the `defaultCallOptions` contains:

```js
etcd3.get('foo').options({ deadline: Date.now() + 5000 })
etcd3.get('foo').options({ deadline: Date.now() + 5000 });
```

## 1.0.1 2020-06-21
Expand Down
8 changes: 8 additions & 0 deletions src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,15 @@ export class WatchManager {
* Emits a data update on the target watcher.
*/
private handleUpdateResponse(watcher: Watcher, res: RPC.IWatchResponse) {
try {
watcher.emit('data', res);
} catch (e) {
// throw any user errors in a new microtask so they don't get handled
// as a stream error.
setImmediate(() => {
throw e;
});
}
}

/**
Expand Down

0 comments on commit cead70a

Please sign in to comment.