Skip to content

Commit ad17f3b

Browse files
authored
fix: flush after sending build log (#88)
1 parent c07d2c2 commit ad17f3b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

buildlog/coder.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,14 @@ func (c *agentClientV2) Send(level codersdk.LogLevel, log string) error {
8383
if err != nil {
8484
return xerrors.Errorf("send build log: %w", err)
8585
}
86+
err = c.flush()
87+
if err != nil {
88+
return xerrors.Errorf("flush: %w", err)
89+
}
8690
return nil
8791
}
8892

89-
func (c *agentClientV2) Close() error {
90-
defer c.cancel()
93+
func (c *agentClientV2) flush() error {
9194
c.ls.Flush(c.source)
9295
err := c.ls.WaitUntilEmpty(c.ctx)
9396
if err != nil {
@@ -96,6 +99,11 @@ func (c *agentClientV2) Close() error {
9699
return nil
97100
}
98101

102+
func (c *agentClientV2) Close() error {
103+
defer c.cancel()
104+
return c.flush()
105+
}
106+
99107
func newAgentClientV2(ctx context.Context, logger slog.Logger, client *agentsdk.Client) (CoderClient, error) {
100108
cctx, cancel := context.WithCancel(ctx)
101109
uid := uuid.New()

0 commit comments

Comments
 (0)