@deffector/standalone 0.1.0 → 0.1.3
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 +2 -0
- package/bin/deffector.mjs +0 -0
- package/dist/public/app.js +9 -9
- package/package.json +1 -1
- package/server.mjs +14 -2
package/package.json
CHANGED
package/server.mjs
CHANGED
|
@@ -16,6 +16,17 @@ const CONTENT_TYPES = {
|
|
|
16
16
|
};
|
|
17
17
|
/** Traces and big state snapshots travel as one message. */
|
|
18
18
|
const MAX_MESSAGE_BYTES = 64 * 1024 * 1024;
|
|
19
|
+
|
|
20
|
+
/** Why a socket closed, when it was not a normal close (page reload, process exit). */
|
|
21
|
+
function describeCloseCode(code) {
|
|
22
|
+
if (code === 1009) {
|
|
23
|
+
return ` — a message was larger than ${MAX_MESSAGE_BYTES / 1024 / 1024} MB; please report this at https://github.com/mxmvshnvsk/deffector/issues`;
|
|
24
|
+
}
|
|
25
|
+
// a normal close, a page reload or a tab that went away
|
|
26
|
+
if ([1000, 1001, 1005, 1006].includes(code)) return '';
|
|
27
|
+
return ` (code ${code})`;
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
/** A panel that has not picked an agent follows the most recently connected one. */
|
|
20
31
|
const AUTO = 'auto';
|
|
21
32
|
|
|
@@ -128,9 +139,10 @@ function createRelay(log) {
|
|
|
128
139
|
for (const panel of agent.panels)
|
|
129
140
|
if (panel.ws.readyState === WebSocket.OPEN) panel.ws.send(text);
|
|
130
141
|
});
|
|
131
|
-
ws.on('close', () => {
|
|
142
|
+
ws.on('close', (code) => {
|
|
132
143
|
agents.delete(id);
|
|
133
|
-
|
|
144
|
+
const name = agent.hello?.app?.name ?? id;
|
|
145
|
+
log(`[deffector] agent disconnected: ${name}${describeCloseCode(code)}`);
|
|
134
146
|
for (const panel of agent.panels) {
|
|
135
147
|
panel.agentId = null;
|
|
136
148
|
pair(panel);
|