Downgrade ExecutionTerminated to debug

Detect closed peer so that subsequent sends don't keep trying and failing
This commit is contained in:
Karl Seguin committed 2026-09-30 07:07:05 +08:00
1 parent 5eaebc9235
commit 7d812cea2e
3 files changed
+17 -2

No files matched your search

+1 -1
View File
@@ -132,7 +132,7 @@ fn run(self: *Watchdog) void {
if (entry.fired == false) {
entry.fired = true;
log.err(.app, "watchdog stall", .{ .stalled_ms = stalled_ms });
log.warn(.app, "watchdog stall", .{ .stalled_ms = stalled_ms });
entry.env.requestTerminate();
}
}
+5 -1
View File
@@ -1255,7 +1255,9 @@ pub fn documentIsLoaded(self: *Frame) void {
self.document._ready_state = .interactive;
self._documentIsLoaded() catch |err| switch (err) {
error.JsException => {}, // already logged
else => log.err(.frame, "document is loaded2", .{ .err = err, .type = self._type, .url = self.url }),
// logged by whatever requested the terminate (watchdog, runaway loop)
error.ExecutionTerminated => log.debug(.frame, "document is loaded", .{ .err = err, .type = self._type, .url = self.url }),
else => log.err(.frame, "document is loaded", .{ .err = err, .type = self._type, .url = self.url }),
};
}
@@ -1359,6 +1361,8 @@ pub fn documentIsComplete(self: *Frame) void {
self._load_state = .complete;
self._documentIsComplete() catch |err| switch (err) {
error.JsException => {}, // already logged
// logged by whatever requested the terminate (watchdog, runaway loop)
error.ExecutionTerminated => log.debug(.frame, "document is complete", .{ .err = err, .type = self._type, .url = self.url }),
else => log.err(.frame, "document is complete", .{ .err = err, .type = self._type, .url = self.url }),
};
+11
View File
@@ -60,6 +60,7 @@ send_arena: ArenaAllocator,
send_depth: u32,
send_timeout_ms: i32,
max_inbox_backlog: usize,
peer_closed: bool,
pub fn init(
self: *Link,
@@ -91,6 +92,7 @@ pub fn init(
.send_depth = 0,
.send_timeout_ms = SEND_TIMEOUT_MS,
.max_inbox_backlog = @as(usize, config.cdpMaxMessageSize()) * INBOX_BACKLOG_MESSAGES,
.peer_closed = false,
};
}
@@ -132,6 +134,10 @@ pub fn releaseSendArena(self: *Link) void {
}
pub fn send(self: *Link, data: []const u8) !void {
if (self.peer_closed) {
return;
}
var pos: usize = 0;
const socket = self.socket;
@@ -157,6 +163,11 @@ pub fn send(self: *Link, data: []const u8) !void {
},
// a signal landed mid-write; nothing was written
error.Interrupted => continue,
error.BrokenPipe, error.ConnectionResetByPeer => {
lp.log.debug(.app, "link peer closed", .{ .err = err });
self.peer_closed = true;
return;
},
else => return err,
};