@webpodjs/net-worker 0.2.0 → 0.2.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.
- package/README.md +5 -3
- package/dist/worker.js +14 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -188,9 +188,11 @@ guest's address from the gateway (a refusal is `reset`). Other loopback addresse
|
|
|
188
188
|
|
|
189
189
|
**The end of a process.** A process's `close` of a connection it ended (`end` first) is close(2) after shutdown: what
|
|
190
190
|
it sent is still delivered, nothing more is reported; without the `end` it is a reset. When it exits it sends
|
|
191
|
-
`{ type: "bye" }` last: `host-socket-close` (which comes on another channel)
|
|
192
|
-
|
|
193
|
-
|
|
191
|
+
`{ type: "bye" }` last: `host-socket-close` (which comes on another channel) ends its listens at once, as an exit
|
|
192
|
+
closes a listening socket (a killed process sends no `bye`, and a dev server restarted at the old one's exit listens
|
|
193
|
+
on the same port right away: nest start --watch), then waits for the `bye` (at most a second), so the response a
|
|
194
|
+
server wrote just before exiting is not lost; then the connections it accepted close that way and the ones it opened
|
|
195
|
+
are reset.
|
|
194
196
|
|
|
195
197
|
TLS is not done in the process (design docs/experiments/e4-host-node.md §7.1): after `tls`, the connection carries the
|
|
196
198
|
plaintext of TLS, which is handled as intercepted HTTPS (the browser checks the certificate). TLS that does not carry
|
package/dist/worker.js
CHANGED
|
@@ -153,27 +153,34 @@ function openHostSocket({ id, port }) {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
/**
|
|
156
|
-
* The process is gone. Its
|
|
157
|
-
*
|
|
158
|
-
*
|
|
156
|
+
* The process is gone. Its listens end at once, as an exit closes a listening socket: another process may take the
|
|
157
|
+
* port right away (a dev server restarted at the old one's exit, nest start --watch; a killed process sends no
|
|
158
|
+
* "bye"). Its port may still hold what it sent last (another channel than this message): until its "bye" (or a
|
|
159
|
+
* second), then the connections it accepted close as a process's exit closes them (what it wrote still goes out),
|
|
160
|
+
* the ones it opened are reset.
|
|
159
161
|
*/
|
|
160
162
|
function closeHostSocketSoon(id) {
|
|
161
163
|
const hs = hostSockets.get(id);
|
|
162
164
|
if (!hs || hs.bye) return closeHostSocket(id);
|
|
165
|
+
unlistenAll(id);
|
|
163
166
|
if (hs.closing) return;
|
|
164
167
|
const t = setTimeout(() => closeHostSocket(id), 1000);
|
|
165
168
|
hs.closing = () => { clearTimeout(t); closeHostSocket(id); };
|
|
166
169
|
}
|
|
167
170
|
|
|
168
|
-
function
|
|
169
|
-
const hs = hostSockets.get(id);
|
|
170
|
-
if (!hs) return;
|
|
171
|
-
hostSockets.delete(id);
|
|
171
|
+
function unlistenAll(id) {
|
|
172
172
|
for (const [p, l] of hostListeners) {
|
|
173
173
|
if (l.owner !== id) continue;
|
|
174
174
|
hostListeners.delete(p);
|
|
175
175
|
pod?.host_unlisten(p);
|
|
176
176
|
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function closeHostSocket(id) {
|
|
180
|
+
const hs = hostSockets.get(id);
|
|
181
|
+
if (!hs) return;
|
|
182
|
+
hostSockets.delete(id);
|
|
183
|
+
unlistenAll(id);
|
|
177
184
|
for (const [local, c] of hs.conns) {
|
|
178
185
|
if (local < 0) pod?.host_end(c);
|
|
179
186
|
pod?.host_abort(c);
|