@dashevo/grpc-common 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@ jobs:
20
20
 
21
21
  - uses: actions/setup-node@v2
22
22
  with:
23
- node-version: '12'
23
+ node-version: '16'
24
24
 
25
25
  - name: Enable NPM cache
26
26
  uses: actions/cache@v2
@@ -11,6 +11,7 @@ class AcknowledgingWritable {
11
11
  * @return {Promise<any>}
12
12
  */
13
13
  write(data) {
14
+ let handler;
14
15
  return new Promise((resolve, reject) => {
15
16
  const callback = (error) => {
16
17
  if (error) {
@@ -18,8 +19,10 @@ class AcknowledgingWritable {
18
19
  }
19
20
  return resolve(true);
20
21
  };
21
- const handler = this.attachHandler(callback);
22
+ handler = this.attachHandler(callback);
22
23
  this.writable.write(data, handler);
24
+ }).finally(() => {
25
+ this.detachHandler(handler);
23
26
  });
24
27
  }
25
28
 
@@ -30,7 +33,6 @@ class AcknowledgingWritable {
30
33
  */
31
34
  createHandler(callback) {
32
35
  const handler = (error) => {
33
- this.detachHandler(handler);
34
36
  callback(error);
35
37
  };
36
38
  return handler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/grpc-common",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Common GRPC library",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -62,8 +62,9 @@ describe('AcknowledgingWritable', () => {
62
62
 
63
63
  const promise = wrapper.write('123');
64
64
 
65
+ // event error is still not detached
65
66
  // eslint-disable-next-line no-underscore-dangle
66
- expect(wrapper.writable._eventsCount).to.be.equal(0);
67
+ expect(wrapper.writable._eventsCount).to.be.equal(1);
67
68
 
68
69
  const result = await promise;
69
70