@nxtedition/lib 20.3.4 → 20.3.5

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.
Files changed (3) hide show
  1. package/couch.js +1 -46
  2. package/http.js +1 -6
  3. package/package.json +1 -1
package/couch.js CHANGED
@@ -943,12 +943,6 @@ class StreamOutput extends stream.Readable {
943
943
  #state
944
944
  #decoder
945
945
  #headers
946
- #startTime = performance.now()
947
- #stats = {
948
- connect: -1,
949
- headers: -1,
950
- ttfb: -1,
951
- }
952
946
 
953
947
  constructor({ signal, highWaterMark = 256 }) {
954
948
  super({ objectMode: true, highWaterMark, signal })
@@ -958,10 +952,6 @@ class StreamOutput extends stream.Readable {
958
952
  return this.#headers
959
953
  }
960
954
 
961
- get stats() {
962
- return this.#stats
963
- }
964
-
965
955
  _read() {
966
956
  this.#resume?.()
967
957
  }
@@ -972,8 +962,6 @@ class StreamOutput extends stream.Readable {
972
962
  }
973
963
 
974
964
  onConnect(abort) {
975
- this.#stats.connect = performance.now() - this.#startTime
976
-
977
965
  if (this.destroyed) {
978
966
  abort(this.errored)
979
967
  } else if (this.#state) {
@@ -987,10 +975,6 @@ class StreamOutput extends stream.Readable {
987
975
  }
988
976
 
989
977
  onHeaders(statusCode, rawHeaders, resume, statusText, headers = parseHeaders(rawHeaders)) {
990
- if (this.#stats.headers === -1) {
991
- this.#stats.headers = performance.now() - this.#startTime - this.#stats.connect
992
- }
993
-
994
978
  if (statusCode >= 300 || statusCode < 200) {
995
979
  throw new Error('invalid status code: ' + statusCode)
996
980
  }
@@ -1000,10 +984,6 @@ class StreamOutput extends stream.Readable {
1000
984
  }
1001
985
 
1002
986
  onData(data) {
1003
- if (this.#stats.ttfb === -1) {
1004
- this.#stats.ttfb = performance.now() - this.#startTime - this.#stats.headers
1005
- }
1006
-
1007
987
  const lines = this.#decoder.decode(data, { stream: true }).split(/\r?\n+/)
1008
988
  lines[0] = this.#str + lines[0]
1009
989
  this.#str = lines.pop() ?? ''
@@ -1049,16 +1029,8 @@ class PromiseOutput {
1049
1029
  #str
1050
1030
  #decoder
1051
1031
  #headers
1052
- #startTime = performance.now()
1053
1032
  #signal
1054
1033
  #abort
1055
- #stats = {
1056
- connect: -1,
1057
- headers: -1,
1058
- data: -1,
1059
- complete: -1,
1060
- error: -1,
1061
- }
1062
1034
 
1063
1035
  constructor({ resolve, reject, signal }) {
1064
1036
  this.#resolve = resolve
@@ -1067,7 +1039,6 @@ class PromiseOutput {
1067
1039
  }
1068
1040
 
1069
1041
  onConnect(abort) {
1070
- this.#stats.connect = performance.now() - this.#startTime
1071
1042
  this.#decoder = new TextDecoder()
1072
1043
  this.#str = ''
1073
1044
 
@@ -1080,10 +1051,6 @@ class PromiseOutput {
1080
1051
  }
1081
1052
 
1082
1053
  onHeaders(statusCode, rawHeaders, resume, statusText, headers = parseHeaders(rawHeaders)) {
1083
- if (this.#stats.headers === -1) {
1084
- this.#stats.headers = performance.now() - this.#startTime - this.#stats.connect
1085
- }
1086
-
1087
1054
  if (statusCode >= 300 || statusCode < 200) {
1088
1055
  throw new Error('invalid status code: ' + statusCode)
1089
1056
  }
@@ -1092,29 +1059,17 @@ class PromiseOutput {
1092
1059
  }
1093
1060
 
1094
1061
  onData(data) {
1095
- if (this.#stats.data === -1) {
1096
- this.#stats.data = performance.now() - this.#startTime - this.#stats.headers
1097
- }
1098
-
1099
1062
  this.#str += this.#decoder.decode(data, { stream: true })
1100
1063
  }
1101
1064
 
1102
1065
  onComplete() {
1103
- if (this.#stats.complete === -1) {
1104
- this.#stats.complete = performance.now() - this.#startTime - this.#stats.data
1105
- }
1106
-
1107
1066
  this.#str += this.#decoder.decode(undefined, { stream: false })
1108
1067
 
1109
- const val = Object.assign(JSON.parse(this.#str), { headers: this.#headers, stats: this.#stats })
1068
+ const val = Object.assign(JSON.parse(this.#str), { headers: this.#headers })
1110
1069
  this.#onDone(null, val)
1111
1070
  }
1112
1071
 
1113
1072
  onError(err) {
1114
- if (this.#stats.error === -1) {
1115
- this.#stats.error = performance.now() - this.#startTime - this.#stats.data
1116
- }
1117
-
1118
1073
  this.#onDone(err)
1119
1074
  }
1120
1075
 
package/http.js CHANGED
@@ -138,8 +138,6 @@ export async function request(ctx, next) {
138
138
  reqLogger.error('request error')
139
139
  }
140
140
 
141
- reqLogger.debug('request ended')
142
-
143
141
  res.end()
144
142
  } else {
145
143
  reqLogger = reqLogger.child({ res, err, responseTime })
@@ -152,10 +150,7 @@ export async function request(ctx, next) {
152
150
  reqLogger.error('request error')
153
151
  }
154
152
 
155
- if (res.writableEnded) {
156
- reqLogger.debug('response completed')
157
- } else {
158
- reqLogger.debug('response destroyed')
153
+ if (!res.writableEnded) {
159
154
  res.destroy()
160
155
  }
161
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "20.3.4",
3
+ "version": "20.3.5",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",