@jsenv/server 12.5.7 → 12.5.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/server",
3
- "version": "12.5.7",
3
+ "version": "12.5.8",
4
4
  "description": "Write your Node.js server using pure functions",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -16,7 +16,8 @@
16
16
  "node": ">=16.13.0"
17
17
  },
18
18
  "publishConfig": {
19
- "access": "public"
19
+ "access": "public",
20
+ "registry": "https://registry.npmjs.org"
20
21
  },
21
22
  "type": "module",
22
23
  "exports": {
@@ -67,4 +68,4 @@
67
68
  "playwright": "1.18.1",
68
69
  "prettier": "2.5.1"
69
70
  }
70
- }
71
+ }
@@ -44,6 +44,34 @@ export const populateNodeResponse = async (
44
44
  }
45
45
 
46
46
  await new Promise((resolve) => {
47
+ const observable = bodyMethods.asObservable()
48
+ const subscription = observable.subscribe({
49
+ next: (data) => {
50
+ try {
51
+ responseStream.write(data)
52
+ } catch (e) {
53
+ // Something inside Node.js sometimes puts stream
54
+ // in a state where .write() throw despites nodeResponse.destroyed
55
+ // being undefined and "close" event not being emitted.
56
+ // I have tested if we are the one calling destroy
57
+ // (I have commented every .destroy() call)
58
+ // but issue still occurs
59
+ // For the record it's "hard" to reproduce but can be by running
60
+ // a lot of tests against a browser in the context of @jsenv/core testing
61
+ if (e.code === "ERR_HTTP2_INVALID_STREAM") {
62
+ return
63
+ }
64
+ responseStream.emit("error", e)
65
+ }
66
+ },
67
+ error: (value) => {
68
+ responseStream.emit("error", value)
69
+ },
70
+ complete: () => {
71
+ responseStream.end()
72
+ },
73
+ })
74
+
47
75
  raceCallbacks(
48
76
  {
49
77
  abort: (cb) => {
@@ -104,34 +132,6 @@ export const populateNodeResponse = async (
104
132
  raceEffects[winner.name](winner.data)
105
133
  },
106
134
  )
107
-
108
- const observable = bodyMethods.asObservable()
109
- const subscription = observable.subscribe({
110
- next: (data) => {
111
- try {
112
- responseStream.write(data)
113
- } catch (e) {
114
- // Something inside Node.js sometimes puts stream
115
- // in a state where .write() throw despites nodeResponse.destroyed
116
- // being undefined and "close" event not being emitted.
117
- // I have tested if we are the one calling destroy
118
- // (I have commented every .destroy() call)
119
- // but issue still occurs
120
- // For the record it's "hard" to reproduce but can be by running
121
- // a lot of tests against a browser in the context of @jsenv/core testing
122
- if (e.code === "ERR_HTTP2_INVALID_STREAM") {
123
- return
124
- }
125
- responseStream.emit("error", e)
126
- }
127
- },
128
- error: (value) => {
129
- responseStream.emit("error", value)
130
- },
131
- complete: () => {
132
- responseStream.end()
133
- },
134
- })
135
135
  })
136
136
  }
137
137