Skip to content

Commit 4dee930

Browse files
committed
Fix frontend log streaming
1 parent e2830c2 commit 4dee930

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

coderd/database/queries.sql.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/provisionerjoblogs.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ FROM
66
WHERE
77
job_id = @job_id
88
AND (
9-
id >= @created_after
10-
OR id <= @created_before
9+
id > @created_after
10+
OR id < @created_before
1111
) ORDER BY id;
1212

1313
-- name: InsertProvisionerJobLogs :many

site/src/xServices/workspaceBuild/workspaceBuildXService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,14 @@ export const workspaceBuildMachine = createMachine(
125125
API.getWorkspaceBuildLogs(ctx.buildId, ctx.timeCursor),
126126
streamWorkspaceBuildLogs: (ctx) => async (callback) => {
127127
return new Promise<void>((resolve, reject) => {
128+
if (!ctx.logs) {
129+
return reject("logs must be set")
130+
}
128131
const proto = location.protocol === "https:" ? "wss:" : "ws:"
129132
const socket = new WebSocket(
130133
`${proto}//${location.host}/api/v2/workspacebuilds/${
131134
ctx.buildId
132-
}/logs?follow=true&after=${ctx.timeCursor.getTime()}`,
135+
}/logs?follow=true&after=${ctx.logs[ctx.logs.length - 1].id}`,
133136
)
134137
socket.binaryType = "blob"
135138
socket.addEventListener("message", (event) => {

0 commit comments

Comments
 (0)