Skip to content

Commit

Permalink
Copy-paste Alyssa's fix
Browse files Browse the repository at this point in the history
Signed-off-by: Rafal Augustyniak <raugustyniak@lyft.com>
  • Loading branch information
Augustyniak committed Nov 2, 2022
1 parent b54adf9 commit 4fc0f22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
23 changes: 1 addition & 22 deletions library/common/extensions/filters/http/platform_bridge/filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,28 +167,7 @@ void PlatformBridgeFilter::onDestroy() {
ENVOY_LOG(trace, "PlatformBridgeFilter({})::onDestroy", filter_name_);
alive_ = false;

auto& info = decoder_callbacks_->streamInfo();
if (response_filter_base_->state_.stream_complete_ && platform_filter_.on_error &&
StreamInfo::isStreamIdleTimeout(info)) {
// If the stream info has a response code details with a stream idle timeout, treat as error.
ENVOY_LOG(trace, "PlatformBridgeFilter({})->on_error", filter_name_);
envoy_data error_message = Data::Utility::copyToBridgeData("Stream idle timeout");
auto& info = decoder_callbacks_->streamInfo();
int32_t attempts = static_cast<int32_t>(info.attemptCount().value_or(0));

auto callback_time_ms = std::make_unique<Stats::HistogramCompletableTimespanImpl>(
config_->stats().on_error_callback_latency_, timeSource());

platform_filter_.on_error({ENVOY_REQUEST_TIMEOUT, error_message, attempts}, streamIntel(),
finalStreamIntel(), platform_filter_.instance_context);

callback_time_ms->complete();
auto elapsed = callback_time_ms->elapsed();
if (elapsed > SlowCallbackWarningThreshold) {
ENVOY_LOG_EVENT(warn, "slow_on_error_cb",
filter_name_ + "|" + std::to_string(elapsed.count()) + "ms");
}
} else if (!response_filter_base_->state_.stream_complete_ && platform_filter_.on_cancel) {
if (!response_filter_base_->state_.stream_complete_ && platform_filter_.on_cancel) {
// If the filter chain is destroyed before a response is received, treat as cancellation.
ENVOY_LOG(trace, "PlatformBridgeFilter({})->on_cancel", filter_name_);

Expand Down
4 changes: 2 additions & 2 deletions test/swift/integration/IdleTimeoutTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static_resources:
}

func onError(_ error: EnvoyError, streamIntel: FinalStreamIntel) {
XCTAssertEqual(error.errorCode, 4)
XCTAssertEqual(error.errorCode, 0)
timeoutExpectation.fulfill()
}

Expand Down Expand Up @@ -159,7 +159,7 @@ static_resources:
client
.newStreamPrototype()
.setOnError { error, _ in
XCTAssertEqual(error.errorCode, 4)
XCTAssertEqual(error.errorCode, 0)
callbackExpectation.fulfill()
}
.setOnCancel { _ in
Expand Down

0 comments on commit 4fc0f22

Please sign in to comment.