Skip to content

Lightpanda: the headless browser designed for AI and automation

fetch can't be navigate mode

Muki Kiboigodb9ccfb7c90d
diff --git a/src/browser/webapi/net/Fetch.zig b/src/browser/webapi/net/Fetch.zig
index c4046269e..03c08a6f1 100644
--- a/src/browser/webapi/net/Fetch.zig
+++ b/src/browser/webapi/net/Fetch.zig
@@ -57,6 +57,12 @@ pub fn init(input: Input, options: ?InitOpts, exec: *const Execution) !js.Promis
resolver.rejectError("fetch init error", .{ .type_error = "Failed to construct Request" });
return resolver.promise();
};
+
+ if (request._mode == .navigate) {
+ resolver.rejectError("fetch request mode error", .{ .type_error = "Fetch can't be navigate" });
+ return resolver.promise();
+ }
+
// This Request is never exposed to JS. makeRequest dupes the url/body
// into the transfer, so nothing references it once we return.
request.acquireRef();
@@ -109,7 +115,7 @@ pub fn init(input: Input, options: ?InitOpts, exec: *const Execution) !js.Promis
.cors => .cors,
.@"no-cors" => .no_cors,
.@"same-origin" => .same_origin,
- .navigate => .navigate,
+ .navigate => @panic("fetch can't be navigate mode"),
},
.origin = exec.origin(),
.redirect = switch (request._redirect) {