From b5e4ad9e306aee51fe7aafb83c6a741780c58705 Mon Sep 17 00:00:00 2001 From: Vlad Yankovenko Date: Wed, 14 May 2025 16:18:44 +0300 Subject: [PATCH 1/5] temporary fix --- .../Core/Node/Combine/Subscription/AsyncNodeSubscription.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NodeKit/NodeKit/Core/Node/Combine/Subscription/AsyncNodeSubscription.swift b/NodeKit/NodeKit/Core/Node/Combine/Subscription/AsyncNodeSubscription.swift index 51f0bb42..007bea8b 100644 --- a/NodeKit/NodeKit/Core/Node/Combine/Subscription/AsyncNodeSubscription.swift +++ b/NodeKit/NodeKit/Core/Node/Combine/Subscription/AsyncNodeSubscription.swift @@ -30,6 +30,8 @@ final class AsyncNodeSubscription>: return Task { let result = await node.process(input, logContext: logContext) _ = subscriber.receive(result) + try? await Task.sleep(nanoseconds: 1_000_000) // Fixes a probable combine bug (Research in progress) + // Approximately 1-4% of requests go to finished before they receive a value subscriber.receive(completion: .finished) } } From 1abd9f2f27e5ea787418876a4147a76087b7b894 Mon Sep 17 00:00:00 2001 From: Anton Boyarkin Date: Tue, 1 Jul 2025 15:39:03 +0300 Subject: [PATCH 2/5] Fix chain metadata override issue --- NodeKit/NodeKit/Chains/ChainBuilder.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NodeKit/NodeKit/Chains/ChainBuilder.swift b/NodeKit/NodeKit/Chains/ChainBuilder.swift index 15898ab8..fdd2488c 100644 --- a/NodeKit/NodeKit/Chains/ChainBuilder.swift +++ b/NodeKit/NodeKit/Chains/ChainBuilder.swift @@ -114,7 +114,7 @@ open class URLChainBuilder: ChainConfigBuilder, ChainBu /// - Parameter root: The chain to which nodes will be added open func metadataConnectorChain( root: any AsyncNode - ) -> some AsyncNode { + ) -> any AsyncNode { let urlRequestEncodingNode = URLJsonRequestEncodingNode(next: root) let urlRequestTrasformatorNode = URLRequestTrasformatorNode(next: urlRequestEncodingNode, method: method) let requestEncoderNode = RequestEncoderNode(next: urlRequestTrasformatorNode, encoding: encoding) From 99453fd0f014bc8a9120167fad7799add8499f46 Mon Sep 17 00:00:00 2001 From: Anton Boyarkin Date: Tue, 1 Jul 2025 16:14:57 +0300 Subject: [PATCH 3/5] Make public init for VoidOutputNode & VoidIONode --- NodeKit/NodeKit/Layers/InputProcessingLayer/VoidIONode.swift | 2 +- .../NodeKit/Layers/InputProcessingLayer/VoidOutputNode.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NodeKit/NodeKit/Layers/InputProcessingLayer/VoidIONode.swift b/NodeKit/NodeKit/Layers/InputProcessingLayer/VoidIONode.swift index 90be5da4..a877e7ef 100644 --- a/NodeKit/NodeKit/Layers/InputProcessingLayer/VoidIONode.swift +++ b/NodeKit/NodeKit/Layers/InputProcessingLayer/VoidIONode.swift @@ -12,7 +12,7 @@ open class VoidIONode: AsyncNode { let next: any AsyncNode - init(next: some AsyncNode) { + public init(next: some AsyncNode) { self.next = next } diff --git a/NodeKit/NodeKit/Layers/InputProcessingLayer/VoidOutputNode.swift b/NodeKit/NodeKit/Layers/InputProcessingLayer/VoidOutputNode.swift index 42f0e6dc..d2b6b75b 100644 --- a/NodeKit/NodeKit/Layers/InputProcessingLayer/VoidOutputNode.swift +++ b/NodeKit/NodeKit/Layers/InputProcessingLayer/VoidOutputNode.swift @@ -12,7 +12,7 @@ open class VoidOutputNode: AsyncNode where Input: DTOEncodable, Input.DTO let next: any AsyncNode - init(next: some AsyncNode) { + public init(next: some AsyncNode) { self.next = next } From a9b7f170864c59436622e8a50fbabd33b06a1e4a Mon Sep 17 00:00:00 2001 From: Nikita Korobeinikov Date: Wed, 2 Jul 2025 14:56:18 +0400 Subject: [PATCH 4/5] add documented comment to AsyncNodeSubscription --- .../Node/Combine/Subscription/AsyncNodeSubscription.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NodeKit/NodeKit/Core/Node/Combine/Subscription/AsyncNodeSubscription.swift b/NodeKit/NodeKit/Core/Node/Combine/Subscription/AsyncNodeSubscription.swift index 007bea8b..7a471c3a 100644 --- a/NodeKit/NodeKit/Core/Node/Combine/Subscription/AsyncNodeSubscription.swift +++ b/NodeKit/NodeKit/Core/Node/Combine/Subscription/AsyncNodeSubscription.swift @@ -8,6 +8,7 @@ /// Combine subscription for ``AsyncNode``. /// Contains base implementation, inheriting from `BaseSubscription`. +/// - Warning: There is small delay between `subscriber.receive(_ input` and `subscriber.receive(completion:` to make sure that input will be published in publisher before completion. final class AsyncNodeSubscription>: BaseSubscription, S> { @@ -30,8 +31,7 @@ final class AsyncNodeSubscription>: return Task { let result = await node.process(input, logContext: logContext) _ = subscriber.receive(result) - try? await Task.sleep(nanoseconds: 1_000_000) // Fixes a probable combine bug (Research in progress) - // Approximately 1-4% of requests go to finished before they receive a value + try? await Task.sleep(nanoseconds: 1_000_000) subscriber.receive(completion: .finished) } } From 06483f722d40828c13d41a08fb2c2d527e122bb0 Mon Sep 17 00:00:00 2001 From: Nikita Korobeinikov Date: Wed, 2 Jul 2025 15:03:03 +0400 Subject: [PATCH 5/5] fix small warning --- .../Layers/ResponseProcessingLayer/ResponseDataParserNode.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NodeKit/NodeKit/Layers/ResponseProcessingLayer/ResponseDataParserNode.swift b/NodeKit/NodeKit/Layers/ResponseProcessingLayer/ResponseDataParserNode.swift index 2f2359d1..be8b4d4c 100644 --- a/NodeKit/NodeKit/Layers/ResponseProcessingLayer/ResponseDataParserNode.swift +++ b/NodeKit/NodeKit/Layers/ResponseProcessingLayer/ResponseDataParserNode.swift @@ -41,7 +41,7 @@ open class ResponseDataParserNode: AsyncNode { await parse(with: data, logContext: logContext) .asyncFlatMap { json, logMessage in let logMsg = logMessage + .lineTabDeilimeter - var log = LogChain(logMsg, id: objectName, logType: .info, order: LogOrder.responseDataParserNode) + let log = LogChain(logMsg, id: objectName, logType: .info, order: LogOrder.responseDataParserNode) guard let next = next else { await logContext.add(log)