Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix web server shutdown on YouTube API errors #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking "Sign up for GitHub", you agree to our terms of service and privacy statement. We'll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
mxpv merged 1 commit into main from claude/issue-837-20260308-2207
Mar 8, 2026
Merged

Fix web server shutdown on YouTube API errors #839

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
14 changes: 11 additions & 3 deletions cmd/podsync/main.go
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"errors"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -194,6 +195,8 @@ func main() {
updates := make(chan *feed.Config, 16)
defer close(updates)

// Save ctx before errgroup so feed updates aren't cancelled by web server lifecycle events
feedCtx := ctx
group, ctx := errgroup.WithContext(ctx)
defer func() {
if err := group.Wait(); err != nil && (err != context.Canceled && err != http.ErrServerClosed) {
Expand All @@ -211,7 +214,7 @@ func main() {
for {
select {
case _feed := <-updates:
if err := manager.Update(ctx, _feed); err != nil {
if err := manager.Update(feedCtx, _feed); err != nil {
log.WithError(err).Errorf("failed to update feed: %s", _feed.URL)
} else {
log.Infof("next update of %s: %s", _feed.ID, c.Entry(m[_feed.ID]).Next)
Expand Down Expand Up @@ -272,11 +275,16 @@ func main() {

group.Go(func() error {
log.Infof("running listener at %s", srv.Addr)
var err error
if cfg.Server.TLS {
return srv.ListenAndServeTLS(cfg.Server.CertificatePath, cfg.Server.KeyFilePath)
err = srv.ListenAndServeTLS(cfg.Server.CertificatePath, cfg.Server.KeyFilePath)
} else {
return srv.ListenAndServe()
err = srv.ListenAndServe()
}
if errors.Is(err, http.ErrServerClosed) {
return nil
}
return err
})

group.Go(func() error {
Expand Down
Loading