Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/runner/LightRunClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class LightRunClient {
if (!lightRunId) return;
fetch(`${this.url}/runs/${lightRunId}/cancel`, {
method: 'POST',
headers: this.headers(),
headers: this.authHeaders(),
}).catch(() => {});
};

Expand Down Expand Up @@ -236,7 +236,7 @@ export class LightRunClient {
async deleteNetwork(name: string): Promise<void> {
const res = await fetch(`${this.url}/networks/${encodeURIComponent(name)}`, {
method: 'DELETE',
headers: this.headers(),
headers: this.authHeaders(),
});
if (!res.ok && res.status !== 404) {
const text = await res.text().catch(() => '');
Expand Down Expand Up @@ -278,7 +278,7 @@ export class LightRunClient {
async stopRun(id: string): Promise<void> {
const res = await fetch(`${this.url}/runs/${id}/stop`, {
method: 'POST',
headers: this.headers(),
headers: this.authHeaders(),
});
if (!res.ok && res.status !== 404) {
const text = await res.text().catch(() => '');
Expand All @@ -291,4 +291,17 @@ export class LightRunClient {
if (this.token) h.authorization = `Bearer ${this.token}`;
return h;
}

/*
* Headers for a request with NO body (stop, cancel, network delete). A
* bodyless request must not declare `content-type: application/json`: Fastify
* rejects an empty body under that content-type with 400
* (FST_ERR_CTP_EMPTY_JSON_BODY), which silently failed service/network
* teardown. Carry only the bearer token.
*/
private authHeaders(): Record<string, string> {
const h: Record<string, string> = {};
if (this.token) h.authorization = `Bearer ${this.token}`;
return h;
}
}
Loading