Skip to content

Commit 0dc7854

Browse files
NotYuShengclaude
andauthored
fix: nginx proxy_read_timeout now respects LLM_TIMEOUT setting (#182)
* fix: log tshark stderr on parse failure Previously stderr was discarded, making it impossible to diagnose why tshark rejected a file. Now stderr is captured and included in both the log message and the thrown exception. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: dark mode text contrast for error message and loading view - ErrorMessage: override hardcoded dark-red title/text colors with light pink tones under [data-theme='dark'] - sgds-overrides: add explicit dark mode rules for .text-body and .text-muted so Bootstrap utility classes respect the dark theme; also wire --bs-body-color and --bs-secondary-color tokens Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: address PR #179 review comments - Replace StringBuilder with StringBuffer for stderrBuf to prevent race condition if join(5000) times out and background thread is still writing - Cache isPrivate() results in computeTopAsns to avoid repeated string parsing per conversation; replace nested ternary with if-else for readability - Remove duplicate [data-theme='dark'] .text-muted rule in sgds-overrides.css Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: nginx proxy_read_timeout now respects LLM_TIMEOUT setting The proxy_read_timeout was capped at 900s regardless of LLM_TIMEOUT, causing nginx to drop long-running story generation requests early while the backend continued and saved the result. Now the timeout is set to max(memory-derived value, LLM_TIMEOUT + 60s) so nginx always waits at least as long as the configured LLM timeout. LLM_TIMEOUT is forwarded to the nginx container in docker-compose.yml. Closes #181 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: harden tshark stderr drainer charset, buffer cap, and logging Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f388069 commit 0dc7854

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

backend/src/main/java/com/tracepcap/analysis/service/PcapParserService.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,14 @@ public PcapAnalysisResult analyzePcapFile(File pcapFile) {
9191
StringBuffer stderrBuf = new StringBuffer();
9292
Thread stderrThread = new Thread(() -> {
9393
try (BufferedReader err =
94-
new BufferedReader(new InputStreamReader(process.getErrorStream()))) {
94+
new BufferedReader(new InputStreamReader(process.getErrorStream(), java.nio.charset.StandardCharsets.UTF_8))) {
9595
String l;
96-
while ((l = err.readLine()) != null) stderrBuf.append(l).append('\n');
97-
} catch (Exception ignored) {}
96+
while ((l = err.readLine()) != null) {
97+
if (stderrBuf.length() < 10_000) stderrBuf.append(l).append('\n');
98+
}
99+
} catch (Exception e) {
100+
log.warn("Failed to drain tshark stderr", e);
101+
}
98102
});
99103
stderrThread.setDaemon(true);
100104
stderrThread.start();

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ services:
110110
environment:
111111
# Memory allocation — nginx body limit and timeouts derived from this
112112
APP_MEMORY_MB: ${APP_MEMORY_MB:-2048}
113+
# LLM timeout — nginx proxy_read_timeout is set to max(memory-derived, LLM_TIMEOUT+60s)
114+
LLM_TIMEOUT: ${LLM_TIMEOUT:-300}
113115
# Timezone Configuration
114116
TZ: Asia/Singapore
115117
ports:

frontend/src/assets/styles/sgds-overrides.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@
316316
color: var(--tp-text) !important;
317317
}
318318

319+
[data-theme='dark'] .text-muted {
320+
color: var(--tp-text-muted) !important;
321+
}
322+
323+
319324
/* Bootstrap utility classes */
320325
[data-theme='dark'] .bg-light,
321326
[data-theme='dark'] .bg-white {

nginx/docker-entrypoint.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ MAX_UPLOAD_MB=$(( MEM * 25 / 100 ))
99
# Nginx body limit = max upload + 50 MB multipart overhead buffer
1010
NGINX_MAX_BODY_SIZE="$(( MAX_UPLOAD_MB + 50 ))M"
1111

12-
# Proxy timeout = 45% of APP_MEMORY_MB, clamped to [300, 900] seconds
12+
# Proxy timeout = max(45% of APP_MEMORY_MB, LLM_TIMEOUT + 60s buffer), floor 300s
1313
NGINX_PROXY_TIMEOUT=$(( MEM * 45 / 100 ))
1414
if [ "$NGINX_PROXY_TIMEOUT" -lt 300 ]; then NGINX_PROXY_TIMEOUT=300; fi
15-
if [ "$NGINX_PROXY_TIMEOUT" -gt 900 ]; then NGINX_PROXY_TIMEOUT=900; fi
15+
LLM_TIMEOUT_S=${LLM_TIMEOUT:-300}
16+
LLM_PROXY_TIMEOUT=$(( LLM_TIMEOUT_S + 60 ))
17+
if [ "$NGINX_PROXY_TIMEOUT" -lt "$LLM_PROXY_TIMEOUT" ]; then NGINX_PROXY_TIMEOUT=$LLM_PROXY_TIMEOUT; fi
1618

1719
export NGINX_MAX_BODY_SIZE
1820
export NGINX_PROXY_TIMEOUT

0 commit comments

Comments
 (0)