Skip to content

Commit caadabd

Browse files
check stream errors in shim
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
1 parent 5555f78 commit caadabd

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

v2/shim_v1.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,55 +409,65 @@ func (s *compatV1ShimServer) RunUserInstance(req *protobuf.UserInstanceRequest,
409409
// enable supported capabilities
410410
if _, ok := instance.(papiv1.Displayer); ok {
411411
if slices.Contains(req.ServerVersion.Capabilities, protobuf.Capability_DISPLAYER) {
412-
stream.Send(&protobuf.InstanceUpdate{
412+
if err := stream.Send(&protobuf.InstanceUpdate{
413413
Update: &protobuf.InstanceUpdate_Capable{
414414
Capable: protobuf.Capability_DISPLAYER,
415415
},
416-
})
416+
}); err != nil {
417+
return err
418+
}
417419
} else {
418420
return errors.New("displayer not supported by server but V1 API does not support backwards compatibility")
419421
}
420422
}
421423
if _, ok := instance.(papiv1.Messenger); ok {
422424
if slices.Contains(req.ServerVersion.Capabilities, protobuf.Capability_MESSENGER) {
423-
stream.Send(&protobuf.InstanceUpdate{
425+
if err := stream.Send(&protobuf.InstanceUpdate{
424426
Update: &protobuf.InstanceUpdate_Capable{
425427
Capable: protobuf.Capability_MESSENGER,
426428
},
427-
})
429+
}); err != nil {
430+
return err
431+
}
428432
} else {
429433
return errors.New("messenger not supported by server but V1 API does not support backwards compatibility")
430434
}
431435
}
432436
if _, ok := instance.(papiv1.Configurer); ok {
433437
if slices.Contains(req.ServerVersion.Capabilities, protobuf.Capability_CONFIGURER) {
434-
stream.Send(&protobuf.InstanceUpdate{
438+
if err := stream.Send(&protobuf.InstanceUpdate{
435439
Update: &protobuf.InstanceUpdate_Capable{
436440
Capable: protobuf.Capability_CONFIGURER,
437441
},
438-
})
442+
}); err != nil {
443+
return err
444+
}
439445
} else {
440446
return errors.New("configurer not supported by server but V1 API does not support backwards compatibility")
441447
}
442448
}
443449
if _, ok := instance.(papiv1.Storager); ok {
444450
if slices.Contains(req.ServerVersion.Capabilities, protobuf.Capability_STORAGER) {
445-
stream.Send(&protobuf.InstanceUpdate{
451+
if err := stream.Send(&protobuf.InstanceUpdate{
446452
Update: &protobuf.InstanceUpdate_Capable{
447453
Capable: protobuf.Capability_STORAGER,
448454
},
449-
})
455+
}); err != nil {
456+
return err
457+
}
450458
} else {
451459
return errors.New("storager not supported by server but V1 API does not support backwards compatibility")
452460
}
453461
}
454462
if _, ok := instance.(papiv1.Webhooker); ok {
455463
if slices.Contains(req.ServerVersion.Capabilities, protobuf.Capability_WEBHOOKER) {
456-
stream.Send(&protobuf.InstanceUpdate{
464+
if err := stream.Send(&protobuf.InstanceUpdate{
457465
Update: &protobuf.InstanceUpdate_Capable{
458466
Capable: protobuf.Capability_WEBHOOKER,
459467
},
460-
})
468+
}); err != nil {
469+
return err
470+
}
461471
} else {
462472
return errors.New("webhooker not supported by server but V1 API does not support backwards compatibility")
463473
}

0 commit comments

Comments
 (0)