From d38a225c78c96462dfafe21205f5dbe9dacbf27f Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 14 Oct 2024 01:42:44 +0200 Subject: [PATCH] fix(VirtualStream): Fix keepAlive flag handling in VirtualStream and added stream closure in tests --- changelog.md | 6 ++++++ test/test.ts | 2 ++ ts/00_commitinfo_data.ts | 2 +- ts/classes.virtualstream.ts | 2 +- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index e5e0179..7bc68ea 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2024-10-14 - 3.1.3 - fix(VirtualStream) +Fix keepAlive flag handling in VirtualStream and added stream closure in tests + +- Ensure that the keepAlive status is correctly maintained in the keepAlive trigger method. +- Added closure of VirtualStreams in the test suite for proper resource cleanup. + ## 2024-10-14 - 3.1.2 - fix(core) Fix incorrect backpressure logic in VirtualStream class diff --git a/test/test.ts b/test/test.ts index e0c1151..8459755 100644 --- a/test/test.ts +++ b/test/test.ts @@ -98,6 +98,8 @@ tap.test('should allow VirtualStreams', async () => { const data = await generatedRequestingVS.fetchData(); const decodedData = new TextDecoder().decode(data); expect(decodedData).toEqual('hello'); + await newRequestingVS.close(); + await newRespondingVS.close(); }); tap.test('should end the server', async (toolsArg) => { diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 5749d3b..df2b448 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@api.global/typedrequest', - version: '3.1.2', + version: '3.1.3', description: 'A TypeScript library for making typed requests towards APIs, including facilities for handling requests, routing, and virtual stream handling.' } diff --git a/ts/classes.virtualstream.ts b/ts/classes.virtualstream.ts index 2d887a8..3ca315c 100644 --- a/ts/classes.virtualstream.ts +++ b/ts/classes.virtualstream.ts @@ -327,7 +327,7 @@ export class VirtualStream implements plugins.typedRequestInterf cycleId: plugins.isounique.uni(), cycle: 'request', mainPurpose: 'keepAlive', - keepAlive: true, + keepAlive: this.keepAlive, }, response: null, }).catch(() => {