Skip to content

Commit

Permalink
fix(BidirectionalStream): fix nested stream will cause nested error (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
rockmagma02 authored Apr 22, 2024
1 parent 579c993 commit eeb9361
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
22 changes: 13 additions & 9 deletions Sources/SyncStream/BidirectionalAsyncStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,19 @@ public extension BidirectionalAsyncStream {

finished = true

let filename = (fileName as NSString).lastPathComponent
let terminated = Terminated(
fileName: fileName,
functionName: functionName,
lineNumber: lineNumber,
columnNumber: columnNumber,
error: error
)
state = .error(terminated)
if let error = (error as? Terminated) {
state = .error(error)
} else {
let filename = (fileName as NSString).lastPathComponent
let terminated = Terminated(
fileName: fileName,
functionName: functionName,
lineNumber: lineNumber,
columnNumber: columnNumber,
error: error
)
state = .error(terminated)
}
await yieldSemaphore.signal()
}

Expand Down
22 changes: 13 additions & 9 deletions Sources/SyncStream/BidirectionalSyncStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,19 @@ public extension BidirectionalSyncStream {

finished = true

let filename = (fileName as NSString).lastPathComponent
let terminated = Terminated(
fileName: fileName,
functionName: functionName,
lineNumber: lineNumber,
columnNumber: columnNumber,
error: error
)
state = .error(terminated)
if let error = (error as? Terminated) {
state = .error(error)
} else {
let filename = (fileName as NSString).lastPathComponent
let terminated = Terminated(
fileName: fileName,
functionName: functionName,
lineNumber: lineNumber,
columnNumber: columnNumber,
error: error
)
state = .error(terminated)
}
yieldSemaphore.signal()
}

Expand Down

0 comments on commit eeb9361

Please sign in to comment.