This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #19 from schickling-assistant/fix/senddata-finish-event

fix: resolve sendData on 'finish' instead of 'close'

authored by

Nathan and committed by
GitHub
(Apr 16, 2026, 3:09 PM +0200) 535c0a2a 86d4a74d

+29 -1
+1 -1
src/client.ts
··· 186 186 process.exit(1); 187 187 }); 188 188 189 - socket.on("close", () => { 189 + socket.on("finish", () => { 190 190 process.exit(0); 191 191 }); 192 192 }
+28
tests/integration.test.ts
··· 1247 1247 client2.destroy(); 1248 1248 }); 1249 1249 } 1250 + 1251 + it("send-style DATA socket resolves 'finish' promptly without waiting for server FIN", async () => { 1252 + const name = uniqueName(); 1253 + await startServer(name, "cat"); 1254 + 1255 + // Simulate the send() pattern: connect, write DATA packets, end, wait for 'finish'. 1256 + // This must resolve quickly — if it hangs, the socket is waiting for the server 1257 + // to send FIN ('close' event) which is unreliable in some container environments. 1258 + const socketPath = getSocketPath(name); 1259 + const start = Date.now(); 1260 + const result = await Promise.race([ 1261 + new Promise<"ok">((resolve, reject) => { 1262 + const socket = net.createConnection(socketPath); 1263 + socket.on("connect", () => { 1264 + socket.write(encodeData("hello from send\n")); 1265 + socket.end(); 1266 + }); 1267 + socket.on("finish", () => resolve("ok")); 1268 + socket.on("error", reject); 1269 + }), 1270 + new Promise<"timeout">((resolve) => setTimeout(() => resolve("timeout"), 3000)), 1271 + ]); 1272 + const elapsed = Date.now() - start; 1273 + 1274 + expect(result).toBe("ok"); 1275 + // 'finish' should fire almost immediately after socket.end(), not after 3s timeout 1276 + expect(elapsed).toBeLessThan(2000); 1277 + }); 1250 1278 }); 1251 1279 1252 1280 describe("STATUS message", () => {